如何刷新对话框内容
我有一个包含部分视图的对话框。 如果用户决定取消对话框而不保存,是否可以撤消用户在对话框内所做的更改?
如果用户现在打开相同的对话框,即使用户取消了该对话框,更改仍然存在。 我知道可以调用控制器并替换部分视图。
还有其他办法吗?
I have dialog tha contains a partialview.
Is it possible to undo changes that the user makes inside the dialog, if the user decides to cancel the dialog and not to save?
If the user now opens the same dialog the changes are still there even if the user cancelled the dialog.
I know that its possible to call the controller and replace the partial view.
Is there any other way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
sanke - 当首次加载部分视图时,您可以将 div 的内容存储在 .data() 元素中。然后,如果它被取消(不保存),只需将 .data() 推回到为对话框创建的 div 中。
行动胜于雄辩:
然后在取消时您可以做相反的事情:
尝试一下......
sanke - you could store the contents of the div in a .data() element when the partialview is first loaded. Then, if it's cancelled (without saving), just push the .data() back in to div that was created for the dialog.
actions speak louder than words:
then on the cancel you could do the reverse:
give it a try...
我对 aspnet mvc 不太了解,但据我了解客户端和脚本,只要你在客户端使用对话框工作,已经插入的内容就会保留在那里,因为对话框是 dom 的一部分页。为了解决此类问题,我通常创建一个“dialog”类,该类将选择器保存到 dialoq 中的不同字段,并在调用 opendialog 方法或取消对话框时初始化为默认值。其中的优点是对话框的所有客户端脚本都包含在一个简洁的 javascript 类中。
I don't know much about aspnet mvc but as far as i know about client side and scripting, as long as you work client side with your dialog, what has already been inserted will stay there as the dialog is part of the dom of the page. To work around this kind of problem i usually create myself a 'dialog' class that holds selectors to different fields within the dialoq and that is initialized to default value either when the opendialog method is called or when the dialog is cancelled. The plus value in that is that all your client side scripting for you dialog is contained within one neat javascript class.