简体   繁体   中英

Getting ui element value of jquery dialog

I have two web form eg webform1 and webform2. i am calling webform2 as dialog from webform1. I want to access ui element(eg hidden field) on click button event of dialog. When focus was on dialog (webform2) then i am able to get hidden filed value in console but when i click on dialog button and code executing button event in JS that time hidden field value becomes undefined.

$(function () {
    $("#dialog").dialog({
        autoOpen: false,
        modal: true,
        width: 950,
        title: "Add Lines to Manual Invoice",
        close: function () {
            $(this).dialog("close");
        },
        buttons: {

            okay: function () {

                console.log($('#HiddenField1').val()) // This is undefined while i want to access webform2 vlaue
                $(this).dialog("close");

            }
        },
        show: {
            effect: "slide",
            duration: 1500
        }
    });
    $("#opener").click(function () {
        $("#dialog").dialog('open');
        return false;
    });
});

i have load webform2 in iframe tag like below:

<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title"><iframe style="border: 1px;height:700px;width:930px;" src="WebForm2.aspx"></iframe></div>

I have resolved this with below line of code.

$(this).find('iframe').contents().find('[id="HiddenField1"]').val()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM