我想在引导模态关闭时触发某些东西。有一个倾听者: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; });
}
}
答案 0 :(得分:3)
openModal: function(modal) {
modal.open();
var that = this;
modal.on('hidden', function() { that.bool = true; });
}