【发布时间】:2013-11-20 21:53:32
【问题描述】:
我遇到了 jquery mobile 没有更新来自控制器的 MVC4 RedirectToAction 调用的 URL 的问题。我已经阅读了其他具有多种解决方案的类似问题,但没有一个对我有用。我希望 jquery 移动加载消息出现在页面之间,所以我不能使用 $.mobile.ajaxEnabled = false 作为解决方案。
起始网址:
//localhost/Application/Demo/Views/FirstPageController/
如果我保留我的代码(如下),它会在应该显示此 URL 时显示相同的 URL:
//localhost/Application/Demo/Views/SecondPageController/Edit
我尝试使用 TempData 来保存控制器内的 dataurl,但最终只是将 dataurl 附加到上述 URL 上。
例如,
//localhost/Application/Demo/Views/FirstPageController/
将显示为
//localhost/Application/Demo/Views/FirstPageController/#Application/Demo/Views/SecondPageController/Edit
而不是
//localhost/Application/Demo/Views/SecondPageController/Edit
如何让它显示下一页的正确网址?
控制器:
[HttpPost]
public ActionResult Index(FirstPageViewModel viewModel)
{
return RedirectToAction("Edit", "SecondPageController");
}
Layout.js(针对所有页面全局运行)
$(document).on("mobileinit", function () {
$.mobile.loader.prototype.options.text = "Loading...";
$.mobile.loader.prototype.options.textVisible = true;
$.mobile.loader.prototype.options.theme = "b";
$.mobile.loader.prototype.options.html = "";
$.ajaxSetup({
beforeSend: function (x, y) {
showProgress();
},
complete: function (x, y) {
hideProgress();
}
});
})
function showProgress(element) {
if (element == undefined) {
$("#FormSubmit").find("input").addClass("ui-disabled");
$("#FormSubmit").find("select").addClass("ui-disabled");
$("#FormSubmit").find("button").addClass("ui-disabled");
$.mobile.loading('show');
}
else {
$(element).addClass("ui-disabled");
$.mobile.loading('show');
}
}
function hideProgress(element) {
if (element == undefined) {
$("#FormSubmit").find("input").removeClass("ui-disabled");
$("#FormSubmit").find("select").removeClass("ui-disabled");
$("#FormSubmit").find("button").removeClass("ui-disabled");
$.mobile.loading('hide');
}
else {
$(element).removeClass("ui-disabled");
$.mobile.loading('hide');
}
}
按钮(来自第一个剃须刀页面)
<input type="submit" data-icon="arrow-r" data-mini="true" data-iconpos="right" name="Continuebutton" value="Continue" />
【问题讨论】:
标签: asp.net-mvc jquery jquery-mobile