我一直在抨擊我的頭靠在牆上,試圖讓這個工作,我終於決定尋求幫助。我必須在我的表單中提交按鈕。一個提交按鈕允許用戶返回。它需要是一個提交按鈕,因爲我仍然需要使用隱藏輸入字段提交的表單。 JQuery.unobtrusive.ajax與「取消」類(MVC 5)不兼容(MVC 5)
<form action="/Question/ProcessQuestion" data-ajax="true" data-ajax-failure="handleError" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-update="#questionForm" data-ajax-url="/Question/ProcessQuestion" id="form0" method="post">
<input type="hidden" name="TraversalId" value="a59aff78-d10c-4800-b91a-3ae47a95a52c">
<input type="hidden" name="AssetId" value="1cf261a6-4549-4802-bd43-f2900178604d">
<input type="hidden" name="Type" value="question/text">
<div id="textQuestion">
<div class="bodyText">
<div>In the space below, describe the problem with the left ankle, using as many details as possible.</div><br>
<textarea rows="10" cols="50" maxlength="999" name="TextResponse" class="textarea" required=""></textarea>
<div class="bigButtons"><br>
<input type="submit" id="btnBack" value="Back" name="buttonType" class="cancel">
<input type="submit" id="btnContinue" value="Continue" name="buttonType">
</div>
</div>
</div>
</form>
正如你所看到的「返回」按鈕,有一個名爲「取消」,在它的類。根據幾個消息來源,即使驗證失敗,也應該提交表單。我遵循stackoverflow的建議。它不起作用。我也看到了asp.net團隊在哪裏表示它已被修復asp.net codeplex,但事實並非如此,因爲它不適合我。
我一直在調試代碼,並且執行永遠不會進入下面的函數。
$(document).on("submit", "form[data-ajax=true]", function (evt) {
var clickInfo = $(this).data(data_click) || [],
clickTarget = $(this).data(data_target),
isCancel = clickTarget && clickTarget.hasClass("cancel");
evt.preventDefault();
if (!isCancel && !validate(this)) {
return;
}
asyncRequest(this, {
url: this.action,
type: this.method || "GET",
data: clickInfo.concat($(this).serializeArray())
});
});
相反textarea的高亮顯示和快速彈出消息指出「請填寫此場」。我相信我做錯了什麼,但是,我不知道它是什麼。我將不勝感激任何幫助。