i working mvc , jquery.
my requirement below: 1. link open popup window. 2. in popup window there search option , search result displayed in table. 3. 1 column of table hyperlinked , clicking on hyperlink close popup window , retrieve value related hyperlink , display text field of parent window.
i have written following code open popup:
<script type="text/javascript"> $(document).ready(function () { $("#lnksupplier").live("click", function (e) { e.preventdefault(); //use or return false var url = $(this).attr('href'); $("#listdialog").dialog({ title: 'find supplier', autoopen: false, resizable: false, height: 650, width: 700, show: { effect: 'drop', direction: "up" }, modal: true, draggable: true,`enter code here` open: function (event, ui) { $(this).load(url); }, close: function (event, ui) { $(this).dialog('close'); } }); $("#listdialog").dialog('open'); return false; }); }); </script> i have written following code json data , place them inside table of popup.
<script type="text/javascript"> $(document).ready(function () { $('#btnsubmit').click(function () { $.getjson('/supplier/supplierlist/' + $('#companyname').val(), function (data) { var items = "<table class='gridtable'><tr><th class='companyname'>company name</th><th class='contactname'>contact name</th><th class='contacttitle'>contact title</th><th class='country'>country</th></tr>"; $.each(data, function (i, supplier) { items += "<tr><td>" + "<a id='" + supplier.supplierid + "' href='create/'" + supplier.supplierid + " class='link' >" + supplier.companyname + "</a></td><td>" + supplier.contactname + "</td><td>" + supplier.contacttitle + "</td><td>" + supplier.country + "</td></tr>"; }); items += "</table>"; $('#suppliers').html(items); }); }) when click on hyper link in table column 'companyname' popup close automatically. have written following code close popup , retrieve the value parent window.
var val = ''; $("a.link").live('click', function (e) { e.preventdefault(); val = this.id; $('#listdialog').dialog('close'); }); but popup not closing. if remove "e.preventdefault()" statement parent window refreshed , data available in disappeared. not right! how can close popup without reloading parent window after retrieving value popup.
thanks in advance. partha
jquery('#simple-dialog-container').trigger('click'); try this, it's not cleanest solution, recommended in cases.
Comments
Post a Comment