jQuery UI Dialog Error

Posted on 2014-01-24
Last Modified: 2014-02-06
Hello Experts!

Have any of you run into the following error, and found the solution?

I have code similar to the following:

var $dialog = $('<div></div>');

function popup() {
	var title = "Question";
	var html = "Would you like to do this?";
		title: title,
		resizable: false,
		buttons: {
			" Yes ": function() {
				$( this ).dialog( "close" );
			" No ": function() {
				$( this ).dialog( "close" );

Open in new window

However whenever I click on one of the buttons, I get a "cannot call methods on dialog prior to initialization; attempted to call method 'close'" error.

I'm using jquery-ui version 1.10.4 (the latest version.)
Question by:OmniUnlimited
  • 4
  • 2
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39808344
hm, your code seems to work fine in my sample jsfiddle:

Can you post a link to your page or attach your complete page?
Seems that the issue is coming from somewhere else / dependent from the rest of the page/script.

LVL 17

Author Comment

ID: 39809354
Did I mention that the problem only happens in IE?  Probably not, huh?

Sorry about that.  It appears that this little omitted fact is probably key to my problem as I can't even get your jsfiddle to work in my IE 8.
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39809880
OK - so its a browser specific / IE8 issue. I have to make a local test as jsFiddle does not run in IE8.

With which browser do you get the error? The jsFiddle works with IE11 (as well as simulated IE10 and 9).

Will be back soon - thanks.
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 17

Author Comment

ID: 39811151
I get the error in IE 8.
LVL 17

Accepted Solution

OmniUnlimited earned 0 total points
ID: 39827326
Sorry, I found an extra $( this ).dialog( "close" ); in the yes and no functions.
LVL 17

Author Closing Comment

ID: 39838445
There would be no solution to this other than fixing the error in the yes and no functions.

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now