Skip to content Skip to sidebar Skip to footer

Migrating From Prototype To Jquery

I am migrating my js lib from prototype to jquery. However, I don't know how to replace the following code: var utilityMethods = { autoHide : function(element) {

Solution 1:

You extend JQuery objects like so:

var utilityMethods = {     
    autoHide : function(element) {
           //...
    }
};

jQuery.fn.extend(utilityMethods);

More info: http://docs.jquery.com/Core/jQuery.extend

Solution 2:

Actually, jQuery specifically avoids extending the DOM. Having recently completed a migration from Prototype to jQuery, this was one of the selling points for me. Instead, you extend jQuery itself. Selecting a DOM object with jQuery gives you a jQuery object that contains a reference to one or more DOM objects. Any method calls on the jQuery object (including your custom utility methods) operate on the DOM elements referenced by that jQuery object.

Post a Comment for "Migrating From Prototype To Jquery"