这是这种情况:
有一个带有许多输入字段的界面和一个“保存”按钮来更新输入。保存将包括许多过程,例如验证、用户确认、添加评论或取消更新。
要离开此界面,有许多选项,例如单击选项卡、单击不同的按钮、按键盘快捷键等。
当用户试图离开时,预期的行为是系统应该检查未更新的字段,如果有的话,它应该要求用户更新或忽略它。
如果用户选择“忽略”,没问题,继续导航。
但是如果用户选择“更新”,那么系统应该暂停当前导航并执行包含许多其他过程的更新处理程序。在成功完成这些更新程序后,系统应从暂停点继续暂停界面导航过程。
对于示例:
//something like this
$('#nxtPage').live("click", function(){
if (any field value changed){
var usrConf = confirm('You wanna update?')
if (usrConf){
// proceed with the updating processes by calling them
callDefaultFldUpdate(); // where this function includes many other procedures, so the return status wont help.
}
}
// the default page navigation process starts here
moveToNextPage();
}
因此,在更新程序之后,系统应继续进行导航程序。
希望情况很清楚,并期待大家提出有用的建议来使用 javascript && jquery 构建这个逻辑。
提前致谢。