...或者为什么$(this).dialog()
在使用动态HTML时在Firefox中失败?
我有一个点击事件,在网页上打开一个jQuery模式对话框,并且它在Chrome和IE中工作正常,但在Firefox中无法正常工作。
下面是相关的代码:
var dialogId = 'uniqueName-' + Math.floor(Math.random() * 1000)
var dialogDiv = $(document.createElement('div')).attr("id", dialogId);
dialogDiv.load(this.href, function() {
var dialog = $(this).dialog({ autoOpen: false });
...
});
在Firefox 11,$(this).dialog({ autoOpen: false })
失败,出现以下错误消息:
$(本).dialog不是函数
但在IE 9中,Chrome 17的一切工作正常。任何线索为什么是这样?
UPDATE:
这里是我的document.ready
函数,其中上面的代码了。我删除它来简化事情。 ALERT A在ALERT B之前发生。ALERT A表示[object Object]
。 ALERT B发生在我点击一个链接时,它说'undefined'
。
$(function() {
alert($.ui); // ALERT A
// Wire up the click event of any dialog links
$('.dialogLink').live('click', function() {
alert($.ui); // ALERT B
return false;
});
});
更新2:
现在我销指出问题出在哪里来临从我转述我的问题,并张贴最小代码重现原来的问题就在这里:Why is FF on OS X losing jQuery-UI in click event handler?
你可以使用console.log或简单的警报来检查jquery是否工作正常吗?此外,如果它的jQuery UI,使用萤火虫来检查它是否加载ff罚款! – 2012-03-27 04:53:11
@MarshallMathews:jQuery工作正常,因为dialogDiv用$(document.createElement('div'))。attr(“id”,dialogId)正确初始化。我用萤火虫检查了这个。你将如何去检查jQuery-UI是否可以用Firebug加载? – 2012-03-27 17:21:20
'console.log(“这解释了对话方法:”+ $ .ui.dialog)'如果为false,那么UI可能没有加载正确 – 2012-03-27 18:16:10