开发者

How i can return jSon Data from jQuery Dialog to Parent form

can anybody say "how i can pass jSon Data from jQuery dialog form to Parent form?" I want to create a search window where user will select client name then selected client name and id will appear in parent form using ASP.net开发者_运维知识库 MVC 3.

Thanks in advance.


JQUERY Dialog is not a separated window. You can access all parent's elements from dialog window using their names or IDs or some other attribute. Consider you want to send your JSON data to a javascript function. Some code lines like what I wrote here can help you:

<script>
    $(function() {
    $( "#dialog-confirm" ).dialog({
        resizable: false,
        height:140,
        modal: true,
        buttons: {
        "Yes": function() {
            $( this ).dialog( "close" );
            some_javascript_function(JSON_DATA);
        },
        "No": function() {
            $( this ).dialog( "close" );
        }
    }
    });
</script>

No matter you write above script in the HTML file or a separated js file, you just need to be sure that your javascript function is known there.


Why does it need to be json? You can just set the elements via javascript directly.

document.getElementById("SomeTextBox").value = "xyz";

You may have to reference the parent using parent.document see this for more details:

http://thedesignspace.net/MT2archives/000105.html#.Tk9WrVuCrxE

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜