1

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

});
0

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

8 Comments

unfortunately I wish this was a simple var naming problem. I made sure same variables are used, and same error occurs.
@Kim - In these cases you're still passing no parameter, meaning it's still undefined, resulting in the same error, you have to actually pass the mycontent parameter, or give it a default...it'll be undefined otherwise. I appreciate the downvote...you're dismissing the answer after you corrected one facet here, but you still have the same problem, you're passing undefined to .html(var).
sigh. I wrote that quick example and didn't write it properly. which is why you are addressing the wrong problem. my bad, fixed the original example code. however the error still ensues. I don't know why it's almost like jquery-ui.js is not loaded but firebug shows it has.
@Kim - Did you read my updated answer? It's the same issue, the variable being passed to .html(var) is undefined, even in your current question. Also when you downvote have a reason, the question being wrong (when the answer fixes that question) isn't really a valid reason, and will drive people off from answering your questions in the future :)
I downvoted because you were stating the obvious and not reallly addressing the intended problem. However, it was badly written example, so I see why you are angry since you did provide a correct solution to the poorly written example. In the end, nothing is solved. I have upvoted anyways but won't be accepting this answer as it is right now.
|
1

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/

1 Comment

you know I am always open to better solutions. Thanks for the suggestion will have a look at it. You were right, there shouldn't be any other reason why this shouldn't work, and yes, it was no the code but simply the javascript running on another application, the application itself was causing issues. tested teh same javascript in other places and it runs fine !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.