我有这些代码,它们被认为是两个函数的bug和触发事件。然而,由于某些原因,该事件似乎不会触发。它们会像预期的那样登录到控制台,但事件永远不会触发。
//Show backstage event
(function( $, oldRem ){
backstage.show = function(){
console.log("yup, I'm the right one");
var resp = oldRem.apply( this, arguments );
$("#backstageArea").trigger("showBackstage");
return(resp);
};
})( jQuery, backstage.show );
//Hide backstage event
(function( $, oldRem ){
backstage.hide = function(){
console.log("And so am I.");
var resp = oldRem.apply( this, arguments );
if(anim && config.chkAnimate) {setTimeout( 'jQuery("#backstageArea").trigger("hideBackstage")', config.animDuration);}
else {$("#backstageArea").trigger("hideBackstage");}
return(resp);
};
})( jQuery, backstage.hide );
//Resize never logs its console message.
jQuery.bind("hideBackstage", function(){topbar.resize();});
jQuery.bind("showBackstage", function(){topbar.resize();});发布于 2012-09-26 21:53:24
您需要指定要bind到的元素,因此尝试:
jQuery("#backstageArea").bind(...而不是
jQuery.bind(...(如果您使用的是jQuery版本的1.7+,您可能希望切换到.on() method -对于此目的将具有相同的效果,但这是从v1.7开始的推荐方式。)
https://stackoverflow.com/questions/12603044
复制相似问题