Avatar of cookers
cookers

asked on 

Getting Jquery dialog to work

I would like some help in getting Jquery Dialog working. So far I have used Jquery tutorials to get going but have reached a bit of a cul de sac. I am trying to fire a JQ dialog from a javascript and  not from a click. The dialog fires OK but im at a loss trying to catch its returns.  So I have the following.

In the document ready script

jQuery('#remove_dialog').dialog({
            autoOpen: false,
            width: 400,
            modal: true,
            resizable: false,
            buttons: {
                "OK": function() {
            jQuery(this).dialog("close");
                    return true
                },
                "Cancel": function() {
                    jQuery(this).dialog("close");
                return false
                }
            }
        });
      
and a div with the dialogue
<div id="remove_dialog" title="Confirm Action ">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 0 0;"></span> You clicked to remove car:</p>
<p id="dialog-rego"></p>
<p>Click "OK" to remove.</p>
<p>If not, click Cancel.<p>
</div>
and the function which fires the dialog

function remove(){
var iFrame =  document.getElementById('formsframe')
OForm=iFrame.contentDocument.getElementsByTagName('form')[0]
carreg =  OForm.registration.value;

document.getElementById('dialog-rego').innerHTML=carreg
return jQuery('#remove_dialog').dialog('open');

reggo=loadTextDoc("POST","php/remove.php?q="+carreg,false);
warning(carreg+ " has been removed from the database");
return false;
}
So..how do I catch and interpret the returns from the dialog, control doesnt appear to pass back to the remove function.

Thanks for any help
jQuery

Avatar of undefined
Last Comment
cookers
Avatar of Jon Norman
Jon Norman
Flag of United Kingdom of Great Britain and Northern Ireland image

return stops the current script and returns the value you specify, you want:

function remove(){
  var iFrame =  document.getElementById('formsframe')
  OForm=iFrame.contentDocument.getElementsByTagName('form')[0]
  carreg =  OForm.registration.value;

  document.getElementById('dialog-rego').innerHTML=carreg
  if( jQuery('#remove_dialog').dialog('open')){
    reggo=loadTextDoc("POST","php/remove.php?q="+carreg,false);
    warning(carreg+ " has been removed from the database");
    return false;
  }
}

Open in new window


I have left the return false at the bottom of your script, I don't know what you want to return from remove();
Avatar of cookers
cookers

ASKER

Thanks..I tried the script you suggested with no luck. The dialog returns [div#remove_dialog.ui-dialog-content] in response to the line " if( jQuery('#remove_dialog').dialog('open'))" and it returns it immediately before a button is selected in the dialog. It is returning data from the div containing the dialog parameters so maybe I should try another way of scripting the dialog
Avatar of Jon Norman
Jon Norman
Flag of United Kingdom of Great Britain and Northern Ireland image

OK, will try this out on jsfiddle, will get back to you with an answer in a bit.
ASKER CERTIFIED SOLUTION
Avatar of Jon Norman
Jon Norman
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of cookers
cookers

ASKER

Thanks, next step for me now that is solved is to move from old fashioned AJAX to jquery AJAX..wish me luck
jQuery
jQuery

jQuery (Core) is a cross-browser JavaScript library that provides abstractions for common client-side tasks such as Document Object Model (DOM) traversal, DOM manipulation, event handling, animation and Ajax. jQuery also provides a platform to create plugins that extend jQuery's capabilities beyond those already provided by the library.

19K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo