user39653 user39653 - 1 month ago 19
jQuery Question

Updating a jQuery-UI Dialog

I have a jQuery-UI Dialog that contains a select list that can get updated by another process. I need to know how to force the Dialog to use the updated select list. I update the select list via $.getJSON() but I don't know how to get the Dialog to use the updated select. I've tried dialog("destroy") on close/cancel but I don't know how to bring it back again after I've done that.

Here's the code I use to update the select element. I believe it's updating the element correctly but the dialog doesn't see the change the next time I open the dialog.

$.getJSON('AJAX/GetGroups.php', function(j){
var options = '';
for( var i = 0; i < j.length; i++ )
options += '<option value="' + j[i].value + '">' + j[i].text + '</option>';

$("#userGroups").html(options);
});

Answer

You don't need to destroy the dialog...you need to update the select list. You should have some identifier or class on the select list which you can modify using jQuery. Please post some relevant HTML to get a more detailed solution.

Comments