jquery - Javascript, returning value from a callback -


i have 3 functions in javascript:

function a(){      b(data); }  function b(data){     element.on('click',function(){          c(data);     }); }  function c(data){     //process data } 

function c data processing, data needs passed on click event, have defined in b. so, need pass data b too, ensure c gets it. here, main program , i'd rather not define click event there. there other way pass data directly c a?

is there other way pass data directly c a?

you need pass call of c th data b that:

function a(){     b(function(){          c(data);     }); }  function b(data){     element.on('click', callback); }  function c(data){     //process data } 

it work same way code have, has decoupled b c.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -