OK, How much of this is right?

jQuery.Map = {
     // this is a public global attribute?
     // ie: global across all instances of jQuery.Map
     whatever : null,

     // a public function
     init : function(options)
     {
         // this is the jQuery search collection
         // self is a private pointer to the collection
         var self = this;

         // another private variable scoped to the function
         var _maph     = 0;

         // an public attribute, accessed via $("#map").Map._maph
         this._maph    = 0;

         // a method, accessed via $("#map").Map.recenter(x,y,dxy)
         this.recenter = function(x, y, dxy)
         {
             console.log("calling recenter()");

         };

         return this.each(
             function(options) {

                 // this is each respective object in the collection
                 // this is a DOM object not a jQuery object

                 // here I can modify the DOM, bind events, etc

             };
     };

// This extends jQuery with my plugin
jQuery.fn.extend(
     {
         Map : jQuery.Map.init
     }
);

// I access my plugin via:
$("#myMap").Map({ <options hash> });

// later I can access a public function on this object like:
$("#myMap").Map.recenter(x, y, dxy);

Is this right? I probably have some terminology mixed up.

-Steve

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

Reply via email to