当我点击AddNewTeam()按钮时,我应该将所有字段都清空。
保存和添加团队的代码:
function AddNewTeam() {
$('#teamdialog').dialog({
resizable: false,
autoOpen: true,
height: 210,
width: 350,
modal: true
});
}
function SaveNewTeam() {
var team = RetrieveTeam();
var IsChecked = $(IsAssociation).is(":checked");
var url = (IsChecked) ? "/Administration/SaveNewTeamforIsAssociation" : "/Administration/SaveNewTeam";
var TeamUserID = $('#teamteam :selected').val() > 0 ? $('#teamteam :selected').val() : 0;
$.ajax({
type: "POST",
url: url,
data: {"teamstring" : JSON.stringify(team), "TeamUserID" : TeamUserID},
datatype: "json",
success: function (teamID) {
if (teamID > 0) {
GetTeams();
$('#teamdialog').dialog('close');
}
else {
alert("Unable to create Team.");
}
}
});
}
并开始观看部分:
<td style="width: 33%">
<fieldset>
<legend>Team</legend>
<select id="teamselect" size="10" onchange="GetRolls()">
</select>
<br />
<input id="addnewteambutton" disabled="disabled" type="button" class="btn" value="Add Team" onclick="AddNewTeam();" />
</fieldset>
</td>
<div id="teamdialog" title="Add Team" style="display: none;">
<table>
<tr>
<td>
<label>Team ID:</label></td>
<td>
<input id="teamidtext" type="text" style="width: 100px;" maxlength="6" /></td>
</tr>
<tr>
<td>
<label>Team Name:</label></td>
<td>
<input id="teamtext" type="text" style="width: 200px;" /></td>
</tr>
<tr>
<td>
<label>Is Association</label></td>
<td>
<input name ="isAssociationcheckbox" type ="checkbox" id="IsAssociation"/>
</td>
</tr>
<tr id="tdteam">
<td>Team Name:</td>
<td>
<select id="teamteam" style="width:150px;">
<option value ="0"></option>
@foreach (RMS.UserService.User u in Model.TeamTeams)
{
<option value="@u.UserID">@(u.FirstName + " " + u.LastName )</option>
}
</select>
</td>
</tr>
</table>
<input type="button" class="btn" value="Create Team" onclick="SaveNewTeam();" />
</div>
现在点击SaveNewTeam()按钮后,新团队正在保存,但是当我打开AddNewTeam时,我得到的是以前输入的值,我不应该这样做。我的问题是如何在单击AddNewGroup()按钮时重置打开的新窗口。
感谢您的帮助.. !!!
答案 0 :(得分:0)
您是说输入中存储了历史记录吗?
在页面开头尝试此操作
$('input[type=text]').attr('autocomplete','off');
它将停止每个文本字段自动填充
答案 1 :(得分:0)
我知道这可能听起来很老套,但在
之前$('#teamdialog').dialog('close');
尝试添加:
$('#teamidtext').val('');
$('#teamtext').val('');
$('#isAssociationcheckbox').prop('checked', false);
$('#teamteam').val('');
此代码在提交后清除表单。我刚刚意识到你想要点击addnewteambutton按钮来实现它。首先,您必须使用
启用它$('#addnewteambutton').prop('disabled', false);
然后添加
$(function () {
$('#addnewteambutton').click(function () {
// insert here the code I've wrote
});
});