Javascript 将此应用于jQuery回调
我想在引导模式关闭时触发一些东西。这有一个侦听器:Javascript 将此应用于jQuery回调,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我想在引导模式关闭时触发一些东西。这有一个侦听器:modal.on('hidden',function(){..}) 我的问题是,我想更改只能使用this引用的对象的值,但在模式回调中,this引用模式。下面是我的代码的外观: return { bool: false, openModal: function(modal) { modal.open(); // this part doesn't work because this refers to the jQ modal o
modal.on('hidden',function(){
..})
我的问题是,我想更改只能使用
this
引用的对象的值,但在模式回调中,this
引用模式。下面是我的代码的外观:
return {
bool: false,
openModal: function(modal) {
modal.open();
// this part doesn't work because this refers to the jQ modal object instead of the current object
modal.on('hidden', function() { this.bool = true; });
}
}
再过7分钟,我就可以接受这个答案了。谢谢你,我恨我自己。7分钟后我就能接受这个答案了。谢谢你,我恨我自己。7分钟后我就能接受这个答案了。谢谢你,我恨我自己。7分钟后我就能接受这个答案了。谢谢你,我恨我自己。
openModal: function(modal) {
modal.open();
var that = this;
modal.on('hidden', function() { that.bool = true; });
}