refactoring - When using jQuery .each(), is it possible to use a non-anonymous function? -


i have code block find particularly long , hard udnerstood : call stack full of implicit functions , paramters implicitely added it. in other words, clarify code separating function called in each each itself.

look example :

$(xml).find('group').each(function () {     var groupname = $(this).attr('name');     // there here around 100 lines of codes split in      // @ least 5 functions, , i'm sure possible use named functions     // instead of implicit ones, no ? 

try passing function reference

live demo

$(xml).find('group').each(myfun);  function myfun(i, item) {     alert(item.id); } 

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 -