我希望在引导程序模式关闭时触发一些事件。有一个监听器: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; });
 }
}

最佳答案

openModal: function(modal) {
  modal.open();

  var that = this;
  modal.on('hidden', function() { that.bool = true; });
 }

10-01 14:46
查看更多