Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery绑定stoppropagation回调上下文_Jquery_Callback_Bind_Stoppropagation - Fatal编程技术网

jquery绑定stoppropagation回调上下文

jquery绑定stoppropagation回调上下文,jquery,callback,bind,stoppropagation,Jquery,Callback,Bind,Stoppropagation,我试图阻止多个事件触发 我使用回调函数传递对象,如下所示: function init() { var myObj = this.someObject; $('#id').bind("blur keyup change", function (e, obj) { return function () { SomeFunction(e, obj); } } (this, myObj)); } function

我试图阻止多个事件触发

我使用回调函数传递对象,如下所示:

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
}
错误在于它找不到函数stopPropagation

这是因为我在调用函数中将“This”赋值给e


我如何才能访问SomeFunction中的“事件”?

我想您应该这样做:

谢谢。这确实帮助我理解了如何正确传递对象。我现在在上下文中遇到了问题,我无法再通过“e”访问根变量。在我可以访问e.nameid之前,请参阅,但现在它还未定义。我发现,我还需要将ctx传递给函数。