您可能希望将选定的选项保存在某处,并在对话框打开时将<select>
的值设置为该保存的值。
像下面的东西应该让你开始。
var orderData = {}; // -- An object to save the data into
var activeEl; // -- Keep track of which button we've clicked
$('#btnOrder1,#btnOrder2').click(function(){
// -- open the dialog
$('#dialog').dialog({
title:'Order Options',
modal: true
});
// -- set the last clicked button to the ID of the one we clicked...
activeEl = this.id;
// -- set the select's option to the value we've stored.
// -- Unless we don't have a value, in which case we'll use "empty".
$('#selOrderOption').val(orderData[activeEl] || '');
});
// -- set up the save click handler
$('#btnSave').click(function(){
// -- save the selected value, keyed by the active button's ID
orderData[activeEl] = $('#selOrderOption').val();
$('#dialog').dialog("close");
});
http://jsfiddle.net/daveSalomon/7Lds66td/
您可以张贴的jsfiddle什么你目前有哪些? – 2014-11-06 21:52:52