在Firefox中访问全局事件对象 [英] Access global event object in Firefox
问题描述
.ajaxStart()
上运行一些函数,但只能在特定事件触发时运行。 b 代码:
$('#loading_indicator')。 ajaxStart(function(){
if(event!= null){
if(event.type =='hashchange'|| event.type =='DOMContentLoaded'){
$( this).show();
$('#acontents')。hide();
$(this).ajaxComplete(function(){
$(this).hide() ;
$('#acontents')。show();
bindClickOnTable();
initFilterInput();
});
}
}
});
问题:这在Firefox中不起作用。在Internet Explorer和Chrome浏览器中,我可以愉快地访问事件对象,而不必将它传递给 .ajaxStart(function()
。然而,在Firefox中,事件对象是 undefined
。
明显但不正确的解决方案:传递事件
对象的函数,这是行不通的,因为它会通过ajaxStart事件,我的检查将不再起作用。
问题: / strong>如何在此函数中访问全局事件对象?
可以在其他函数中使用。
下面是演示: http: //jsfiddle.net/cVDbp/
The goal: run some functions on .ajaxStart()
but only if fired by a certain event.
The code:
$('#loading_indicator').ajaxStart(function() {
if(event != null){
if(event.type == 'hashchange' || event.type == 'DOMContentLoaded'){
$(this).show();
$('#acontents').hide();
$(this).ajaxComplete(function() {
$(this).hide();
$('#acontents').show();
bindClickOnTable();
initFilterInput();
});
}
}
});
The problem: This does not work in Firefox. In Internet Explorer and Chrome I can happily access the event object without passing it to the .ajaxStart(function()
. In Firefox however, the event object is undefined
.
The obvious but incorrect solution: pass the event
object to the function. this will not work because it will pass the ajaxStart event and my checks will not work anymore.
The question: How do I make the global event object accessible within this function?
You can store event Object in any variable than can use in other function.
Here is the demo : http://jsfiddle.net/cVDbp/
这篇关于在Firefox中访问全局事件对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!