1

I want to load a page into jQuery Dialog plugin (by using that code jQuery: Load Modal Dialog Contents via Ajax) In that page user will select some data. After the selection, when he closes the Dialog window, I need to retrieve the user's selected data from that Dialog window. How can I do that ?

1
  • 1
    Hack : During selection in the Dialog window, write values in hidden input tags in the parent window. Commented Oct 7, 2012 at 13:30

1 Answer 1

4

First thing you want to do is have the values saved when the dialog closes. Let's say this is the page you are loading:

<input type="text" id="text1" name="text1" /><br />
<input type="text" id="text2" name="text2" /><br />
<a href="#" id="dialog_submit_button">Click</a>

Then when you load the dialog, you should add this:

jQuery('#dialog').dialog({
    // all you other stuff
    close: function(){
        var in1 = $('#text1').val();
        var in2 = $('#text2').val();
        jQuery.dialog_info = {
            input1 : in1,
            input2 : in2
        }
    }
});

Now, those text values can be pulled anytime you need in the rest of the code with

var value1 = jQuery.dialog_info.input1;
var value2 = jQuery.dialog_info.input2;

Hope that helps

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

Comments

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.