在窗體上使用jquery mobile進行刷新。按下該按鈕後,頁面會刷新,但腳本(頁面上)無法運行(單擊提交時的操作)。下面是頁面的外觀:頁面刷新後腳本失敗
@using (Html.BeginForm())
{
<input type="submit" id="refresh" name="actionType" value="Refresh" />
<input type="submit" id="submit" name="actionType" value="Submit" />
}
@Scripts.Render("~/bundles/jquery")
<script type="text/javascript">
$('#submit').click(function() {
alert('Here');
});
</script>
刷新實現爲:
[HttpPost]
public ActionResult Index(string actionType)
{
if (actionType == "Refresh")
{
return RedirectToAction("Index");
}
...
}
在此先感謝您的幫助!
它的工作原理,謝謝!但爲什麼選擇'#submit'沒有刷新工作? – Gerard 2013-02-24 14:10:47
說實話我不知道...你提到你使用jQuery手機,所以我想它與jQuery手機相關,儘管你的示例代碼不包含任何與jQuery手機相關的部分。 – nemesv 2013-02-24 14:22:02