...or Why $(this).dialog()
fails in Firefox when using dynamic HTML?
I have a a click event that opens a jQuery modal dialog box on a web page, and it is working fine in Chrome and IE, but not in Firefox.
Here is the pertinent code:
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 });
...
});
In Firefox 11, $(this).dialog({ autoOpen: false })
fails with the following error message:
$(this).dialog is not a function
But in IE 9 an Chrome 17 everything is working fine. Any clue why that is?
UPDATE:
Here is my document.ready
function where the code above was. I removed it to simplify things. ALERT A is occuring before ALERT B. ALERT A says [object Object]
. ALERT B occurs when I click on a link and it says '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;
});
});
UPDATE 2:
Now that I pin pointed where the problem was coming from I rephrased my question and posted the minimal code to reproduce the original problem here: Why is FF on OS X losing jQuery-UI in click event handler?