jquery bind stoppropagation callback context
I am trying to prevent multiple events firing.
I'm using a callback fu开发者_JS百科nction to pass an object, like this:
function init() {
var myObj = this.someObject;
$('#id').bind("blur keyup change", function (e, obj) {
return function () {
SomeFunction(e, obj);
}
} (this, myObj));
}
function SomeFunction(e, obj) {
e.stopPropagation();
//do something with the object
}
The error is that it can't find the function stopPropagation.
This is because I am assigning 'this' to e in the calling function.
How can I get access to the 'event' in SomeFunction?
I think you'll want to do something like this: http://jsfiddle.net/W47Ky/
精彩评论