我已經定義了function
用於內部jqueryui dilaog
顯示一些html
內容的舊的輸入值:JQuery的保存對話框中被破壞後
function ui_window(title, dialogWidth, content,buttons,className)
{
$('<div id="window">').html(content).
dialog({
title: title,
show: 'drop',
hide: 'drop',
width: dialogWidth,
buttons: buttons,
close: function (ev, ui) { $(this).remove(); },
position: { my: 'center', at: 'center', of: window }
}
).addClass(className);
return false;
}
而這裏的另一個JavaScript function
調用上述function
:
function checkForValidCommand()
{
var content = getInnerHTML("#checkForValidCommand");
var myFunc = function()
{
var pensionerID = $('#txtID').val();
alert(pensionerID);
$(this).dialog('destroy');
}
else
$('#txtID').focus();
}
var buttons = [{ text: 'OK', click: myFunc}];
ui_window("Pensioner", 410, content, buttons);
}
當我第一次打電話給「checkForValidCommand
」並且input
a value
進入唯一的textbox
然後按確定我得到一個值爲textbox
的警報。然後當我再次撥打function
,然後按下確定而沒有發送任何內容到textbox
時,我仍然收到alert
與舊的value
。我的代碼中有什麼問題?
編輯:這裏是萬一html內容要看到:
<table>
<tr>
<td align="right">
<label>
Insert the pensioiner's ID:
</label>
</td>
<td>
<input id="txtID" type="text" onkeydown="return onlyNumbers(event);" maxlength="8"/>
</td>
</tr>
</table>
我發現它與對話框上的按鈕有關。因爲如果我關閉對話框而不按下按鈕,並在關閉事件時提醒txtID值,我會得到正確的值。 –