javascript - Questions about jQuery patterns -


so decided learn jquery , needed simple function 1 of projects, started search pattern.

i began official guide found many other possible templates. reference 2 of them ask questions:

first one

second one

the first pattern seems lot more cleaner me, idea of namespace much. but, how used? write whole functions methods of namespace, calling of them in init() , call 1 method init() in iife, or should call necessary methods directly in iife?

i feel question idiotic, can't understand usage.

the second pattern more complicated me. have @ this:

;(function ( $, window, document, undefined ) {     //... })( jquery, window, document ); 

what these parameters, set them , why needed? disadvantage of wrapper in first sample?

the diversity of possibilities overwhelming, don't know start or how figure ot right thing me.

check excellent article on smashing magazine.
covers multitudes of jquery plugin patterns , explains each , every 1 of them.

edit:
there portion of article there answers question :)


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -