What's the difference between jQuery $().each() and implicit iteration? -


i have 2 inputs 2 separate search forms of same page. 1 has data-result-select-url attribute , 1 doesn't.

<input id="q_id_eq" class="foo" type="text" size="30" name="q[id_eq]" data-result-select-url="/products/(id)" tabindex="-1"></input>  <input id="q_id_eq" class="foo" type="text" size="30" name="q[id_eq]" tabindex="-1"></input> 

i write own select2 plugin these inputs.

$ = jquery $.fn.my_select2 = (args) ->   ...   select_url = $(this).data("result-select-url")   if select_url?     $(this).on "change", (e) ->       ...    $(this).select2 args 

when use $().each() call plugiin my_select2(), works fine. 1 input receives "changed" event.

jquery   $('.foo').each ->     $(this).my_select2() 

but if call my_select2() using jquery implicit iterations, both inputs receive event.

jquery ->   $('.foo').my_select2() 

what explanation? looked jquery doc each couldn't find answer.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -