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 opti开发者_运维百科ons = '';
for( var i = 0; i < j.length; i++ )
options += '<option value="' + j[i].value + '">' + j[i].text + '</option>';
$("#userGroups").html(options);
});
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.
In my opinion, you don't have to update the dialog. Your select
is an HTML element like any other. You just have to update the select
values.
精彩评论