Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery-ui, Use dialog('open') and pass a variable to the DIALOG

Tags:

I have the following JS:

$('#listeditdialog').dialog('open'); 

Which opens the following dialog:

$('#listeditdialog').dialog({     autoOpen: false,     resizable: false,     position: ['center',150],     width: 450,     open: function(event, ui) {         $("#listeditdialog").load("/projects/view/tasks/ajax/?listid=" + XXXX);     },     close: function(event, ui) {         $("#listeditdialog").html('<p id="loading"> </p>');     } }); 

My Question is when I use the dialog open function in another JS function, how can I pass a listID variable which I would get fom the click even bind that fired the dialog open func.

Thanks!

like image 482
AnApprentice Avatar asked May 22 '10 21:05

AnApprentice


1 Answers

If I understand you right, you want to have data that you have access to when you call $('#listeditdialog').dialog('open') that's available when the open event fires?

Something like this could help:

// where dialog is opened $('#listeditdialog').data('listID', listIDVarOrSimilar); //assign the ID for later use $('#listeditdialog').dialog('open')  // dialog definition $('#listeditdialog').dialog({     autoOpen: false,     resizable: false,     position: ['center',150],     width: 450,     open: function(event, ui) {         var $led = $("#listeditdialog");         $led.load("/projects/view/tasks/ajax/?listid=" + $led.data('listID'); //use the previously saved id     },     close: function(event, ui) {         $("#listeditdialog").html('<p id="loading"> </p>');     } });` 

http://api.jquery.com/data/

like image 71
Dan Heberden Avatar answered Sep 29 '22 12:09

Dan Heberden