hey gang--

I have a project which is using JQuery as its javascript foundation.  
In that project have a page of modules (div class="pmodule") that i  
would i like extend using Function.prototype or the JQuery equivalent.

what i'd like to do is create a prototype object (with some custom  
methods) and then convert each of those DOM elements into an instance  
of that prototype object, so that each module on the page will then  
attain those custom methods.

here's a simplified version of what i have so far:

function Pmodule() {

};

Pmodule.prototype = {
        doSomething: function() {
                alert(1);
        },
        doSomethingElse: function(somevalue) {
                alert(somevalue);
        }
};

$.fn.pmodule = function() {
        return this.each(function() {
                // here i'd like to convert each <div class="pmodule"> into an  
instance of the Pmodule object
                // so it will have all the private methods defined in that 
object
                // but I'm not sure where to go from here
        });
};

$(document).ready(
        function() {
                $('.pmodule').pmodule();
        }
);


any help at all would be greatly appreciated. if this can be done  
differently/more efficiently in some other way please feel free to  
turn this upside down.

thanks,

-p



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to