Tuesday, July 29, 2014

Easy Javascript class format - Works in all browsers

This is the most easiest java script pattern I found . Its works so nicely with many frameworks (jQuery, ExtJS) . 


Usage

 $(document).ready(function(){
   var mySamplePlugin = new SamplePlugin({ id : a }); //Input your parameters  
   mySamplePlugin.testFunction();                               
 }); 



  Model


var SamplePlugin = function (config) { 
    var p = this; 
    p.id = config.id; 

    p.testFunction = function () { 
      alert(p.id); 
    }; 

 }; 





 Happy Coding Fellows!

No comments:

Post a Comment