How I send to the handler a variable that’s on the outer scope?
i = 1;
$(id).change(function() {myHandler(i)});
i = 2;
When called, the parameter is 2.
Also tried as string, that work in DOM but dont work in jQuery:
$(id).change('myHandler(' + i + ')');
Say you want to pass data object,
In the
myHandlerfunction:The value passes as parameter if modified later wont get reflected.