Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.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
Javascript 将此应用于jQuery回调_Javascript_Jquery_Twitter Bootstrap - Fatal编程技术网

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; });
 }