Pass a variable to JQuery UI dialog

jquery-ui

Solution

You can try using the .data() method to store data for you. Take a look at this answer Passing data to a jQuery UI Dialog

For example to pass a variable, you can store it using the data function, before opening the dialog

$("#dialog_div")
.data('param_1', 'whateverdata')
.dialog("open");

Then you can get this back by:

var my_data = $("#dialog_div").data('param_1')

Problem

I am deleting a record using PHP. I want to use a JQuery UI dialog to confirm the action, but I dont know how to pass a variable (my RecordID) to the redirect URL function, or allow the URL to access `window.location.href`. ``` $("#confirm" ).dialog({ resizable: false, autoOpen: false, modal: true, buttons: { 'OK': function() { window.location.href = 'url and myvar??'; $( this ).dialog( "close" ); }, 'Cancel': function() { $( this ).dialog( "close" ); } } }); $("#delete").click(function() { $("#confirm").dialog( "open" ).html ( "Are U Sure?" ); return false; }); ``` HTML ``` <a href='index.php?recordid=$row[recordid]' id='delete'>DELETE</a> ``` Is there a good way to do this?

Original source

Related problems