(可能)简单的 jQuery 问题在这里。我正在使用 jQuery UI 对话框,并且正在确认。基本上,当用户选择某个选项(结合其他情况)时,我希望能够将他们发送回他们上次选择的选项,或者如果我不能这样做,则返回默认选项。
该选项也没有“选定”属性,这将是我的首选示例。有没有办法做到这一点?
这是js:
alert('hey')
if (document.frm.notNull.checked == true) {
// This is where it ends!
if ($('input[name=valueTextField]').length > 1) {
$('#dialog p').empty();
$('#dialog p').html("You're going to lose your stuff if you do this. You sure you want to?");
$('#dialog').dialog({
autoOpen: true,
width: 600,
modal: true,
buttons: {
"<spring:message code='dialogBox.cancelConfirmation.YES'/>": function() {
$(this).dialog("close");
$("#bottom").css('visibility', 'visible');
$('.edit-new').css('visibility', 'hidden');
$('.edit-trash').css('visibility', 'hidden');
// if table has more than one row, delete the rest.
deleteExtraRows('valueTable');
return true;
},
"<spring:message code='dialogBox.cancelConfirmation.NO'/>": function() {
$(this).dialog("close");
// Need to revert the user back to where they came from here.
$('#control[value=1]').attr('selected', true);
// return false;
}
}
});
} else {
$("#bottom").css('visibility', 'visible');
$('.edit-new').css('visibility', 'hidden');
$('.edit-trash').css('visibility', 'hidden');
// if table has more than one row, delete the rest.
deleteExtraRows('valueTable');
return true;
}
}
这是 HTML(动态呈现):
<div class="lbl">
<label>Control</label>
</div>
<select style="margin:0 0 0 8px; left:15px; position:relative;" name="control"
id="control" onChange="checkTableVisibility();">
<option value=1>Check Box</option>
<option value=0>Dropdown Menu</option>
<option value=3>Radio Button</option>
<option value=2 selected="selected">Text Box</option>
</select>