Question

This jsfiddle.net example includes $H:

new Request.JSON({
    url: '/echo/json/',
    data: {
        json: JSON.encode({
            text: 'some text',
            array: [1, 2, 'three'],
            object: {
                par1: 'another text',
                par2: [3, 2, 'one'],
                par3: {}
            }
        }),
        delay: 3
    },
    onSuccess: function(response) {
        show_response(response, $('post'));
    }
}).send();

show_response = function(obj, result) {
    $H(obj).each(function(v, k) {
        new Element('li', {
            text: k + ': ' + v
        }).inject(result);
    });
    result.highlight();
};

I can't seem to find the meaning/function of $H. Can someone elaborate?

Was it helpful?

Solution

$H is to do with mootools, not jQuery. You find the doc here (pg 67). Excerpt below:

$H is a shortcut to initialize an instance of Hash . Usage :
$H(object) Example : var fooHash = $H({foo: 'bar'}); When you’ll use it : This is just a shortcut for new Hash(obj) , which returns an instance of Hash

OTHER TIPS

$H is just a function, defined by one of the other scripts in (or linked in from) the page. JS identifiers can contain $; it's just used because it looks special (and mortals are so used to the "only word chars" rules for identifiers, that it's unlikely to conflict with other people's stuff).

Look through the other scripts for a function named $H, or for some code that copies/moves $ (a very common name in frameworks, and thus, likely to conflict) to something else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top