Passing Data to a Jquery UI Dialog

Passing data to a jQuery UI Dialog

You could do it like this:

  • mark the <a> with a class, say "cancel"
  • set up the dialog by acting on all elements with class="cancel":

    $('a.cancel').click(function() { 
    var a = this;
    $('#myDialog').dialog({
    buttons: {
    "Yes": function() {
    window.location = a.href;
    }
    }
    });
    return false;
    });

(plus your other options)

The key points here are:

  • make it as unobtrusive as possible
  • if all you need is the URL, you already have it in the href.

However, I recommend that you make this a POST instead of a GET, since a cancel action has side effects and thus doesn't comply with GET semantics...

Pass parameter to jQuery dialog

Try this out:- http://jsfiddle.net/adiioo7/StMyA/

The above code is working fine on my end.

JS:-

$('#dialogSaveConfirmation').dialog({
autoOpen: false,
modal: true,
width: "auto",
buttons: {
"Save": function () {
var nr = $('#dialogSaveConfirmation').data('param');

alert(nr);

}
}});

$("#dialogSaveConfirmation").data('param', "asdsa").dialog('open');

passing parameters to jquery ui dialog

$("#<%=txtDirProprio.ClientID%>").focus(function() 
{
$("#<%=dialog.ClientID%>").data("id","#<%=txtDirProprio.ClientID%>").dialog( "open" );
return false;
});

Have to set the data first before calling .dialog('open');



Related Topics



Leave a reply



Submit