如果要销毁包含未保存数据的视图,则显示警告
如果视图被破坏,当用户采取的操作将导致未保存的更改丢失时,我想向用户显示警告。
I want to display a warning to the user when an action they take will cause the loss of unsaved changes if the view is destroyed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直认为模型拥有
synced
标志会很有用。当您设置任何内容时(默认情况下创建新对象时)会被清除,但在保存
时会被设置。您必须扩展 Backbone.Model 或创建一个新的基类来与您的模型一起使用才能实现这一点,但它将使您能够询问您的模型:“您是否与服务器同步?”I always thought thought that it would be useful for the Model to have a
synced
flag. One that gets cleared when you set anything (and by default when creating a new object) but gets set onsave
. You would have to extendBackbone.Model
or create a new base class to use with your models to make it happen, but it would give you the ability to ask your models: "Are you synced with the server?"