LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-23-2012, 02:02 PM   #1
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Rep: Reputation: 31
Can't get jquery dialog to work


Hey guys,

I'm pretty new to jquery so I am having some trouble wrapping my head around some basic things. This time I am having issues getting a form submit to bring up a dialog where if the user cancels than it does a preventDefault() but if they hit OK then it continues with the submission. Right now when I click the submit button, I am not able to get the dialog to popup at all. Can anyone tell me what I may be missing to get this to work?

Here is the code that I am using to try and get this to work:
Code:
$(document).ready(function(){
  $('#dialog').dialog({
            autoOpen: false,
            width: 400,
            modal: true,
            resizable: false,
            buttons: {
                "Submit Form": function() {
                   document.testconfirmJQ.submit();
                },
                "Cancel": function() {
                    $(this).dialog("close");
                }
            }
        });
  $("#survey_form").submit(function(e){
    alert("alert");
    e.preventDefault();
    $('#dialog').dialog('open');
  });
});
Note: I modified code from what I saw when I was googling around for an answer. I didn't see anything on jquery.com that specifically talked about the dialog function so I am not sure that it exists anymore. If it does not exist, is there another way that I can get this to work? Even if using raw javascript?
 
Old 02-23-2012, 02:20 PM   #2
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 360

Rep: Reputation: 199Reputation: 199
This may sound obvious, but have you included <script src="some.dialog.plugin.js"></script> tag inside your HTML file (and added some.dialog.plugin.js file alongside)? jQuery doesn't have dialog functionality by itself, .dialog() method is provided by some plugin. You can quickly check if .dialog() method is defined by typing inside Firebug (if you're using Firefox for developing) console
Code:
$().dialog
If you get undefined, it means that you're missing the plugin code.

Note: plugin's <script> tag should be added after jQuery's one.
 
Old 02-23-2012, 02:23 PM   #3
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
Ah then that is definitely my issue. I thought this was a built into jquery and I could use a plugin as an alternative. I guess I should hunt around for a plugin worth using and use that I wasn't using any plugins at all.

Thanks a lot for clarification.
 
Old 02-24-2012, 02:08 PM   #4
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
Thanks, using jquery-ui gave me a confirmation dialog I can use.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Jquery and checkboxes suse_nerd Programming 9 11-28-2011 09:43 AM
jquery to dynamically create cookies using the jquery cookie plugin lmcilwain Programming 5 07-27-2011 09:11 PM
Cannot get conditional statements to work in xDialog/Dialog Stevithen Programming 7 02-05-2011 06:03 PM
LXer: jQuery UI—The Dialog: Part 2 LXer Syndicated Linux News 0 02-11-2009 03:40 PM
Ok button on yumex preferences dialog box don't work abhi_deokar Fedora 2 07-08-2007 03:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration