Reputation: 15251
for example I call it via newDialog("This is title !", "this is my content");
function newDialog(mytitle, mycontent){
var $dialog = $('<div id="mydialog"></div>')
.html(mycontent)
.dialog({
autoOpen: false,
modal: false,
title: mytitle
});
$dialog.dialog('open');
return false
}
This is the error
Error: $("").html(mycontent).dialog is not a function
What does this mean ? I have made sure all the jquery-UI, and jquery js files are fully loaded using firebug plugin to confirm all of this.
I don't understand why it would suddenly stop working.
I've tried it with $(document).click(newDialog); and $('body').delegate(':not(#mydialog *, #mydialog)','click', newDialog); but the error is not going away. The latter is used so new dialogs will not spawn if the dialog is accidently clicked.
$(top.document).ready(function () {
var fruits = new Array();
$(document).click(newDialog("happy title", "happy content to keep everyone happy"));
//$('body').delegate(':not(#mydialog *, #mydialog)','click', newDialog);
});
Upvotes: 1
Views: 8863
Reputation: 29658
Check that the dialog
plugin is properly installed. There shouldn't be any other reason why this shouldn't work.
May I take this opportunity for some shameless self-promotion to offer you an alternative. I wrote a jQuery plugin that does what you are trying to do. It's open source if you are interested: http://code.google.com/p/dialogwrapper/
Upvotes: 1
Reputation: 630379
For updated question: You still have the same issues as bfeore, when calling it like this:
$(document).click(newDialog);
It's being called without any parameters, which means .html()
is still getting undefined
passed in. You eiher need to pass parameters, e.g.:
$(document).click(function() { newDialog("Title", "Content"); });
Or give the parameters some defaults, for example:
function newDialog(mytitle, mycontent){
mytitle = mytitle || "Default Title";
mycontent = mycontent || "Default Content";
For original question: Your variables names are off, this:
.html(mycontent)
Should be:
.html(mycon)
Currently, since it's undefined, it's calling .html()
getting a string back, not setting the html. The same is true for the title, your parameter is mytit
, the variable you're trying to use is mytitle
.
Upvotes: 5