javascript - jquery plugin development pattern -
that how implement plugins:
(function($){ $.fn.plugingname = function(insettings){ //code extands settings default return this.each(function(){ new pluginclass($(this), settings); }); } pluginclass = function(jelem, settings){ //here put variable , function in such way compose better var events = { onmouseup : function(){ //some actions }, onmousemove : function(event){ //some actions }, //etc. }, draw = { drawgrid : function(){//some actions}, //etc. }, //etc. /***************************** * place of question ****************************/ } })(jquery);
i want know if there pattern separate algorithm declaration part described above. thing put algorithm part inside
function main(){ }();
if there better approach distinguish main part of algorithm. hope described clear.
all others improvment might done represented code appreciate.
you mean putting function main()
outside of big wrapping function($){ ...
? not desired, wrapping function there reason not overcrap global namespace. clean design , desired. don't worry use standard pattern.
Comments
Post a Comment