Solved

jQuery UI Dialog Error

Posted on 2014-01-24
6
618 Views
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?";
	$dialog.html(html);
	$dialog.dialog({
		title: title,
		resizable: false,
		buttons: {
			" Yes ": function() {
				$( this ).dialog( "close" );
				yes_function();
			},
			" No ": function() {
				$( this ).dialog( "close" );
				no_function();
			}
		}
	});
}

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.)
0
Comment
Question by:OmniUnlimited
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39808344
Hi,
hm, your code seems to work fine in my sample jsfiddle:
http://jsfiddle.net/EE_RainerJ/uun8B/

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.

HTH
Rainer
0
 
LVL 17

Author Comment

by:OmniUnlimited
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.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39809880
Hi,
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.
Rainer
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 17

Author Comment

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

Accepted Solution

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

Author Closing Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

738 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