Javascript 主干:如果输入未更改,则隐藏对话框弹出窗口
如果字段的值为0,我将尝试显示一个对话框弹出窗口。我可以做到这一点,但在渲染页面中,如果输入值为0且未更改,我将再次看到该对话框 如果渲染时输入值为0,则对话框不应存在Javascript 主干:如果输入未更改,则隐藏对话框弹出窗口,javascript,backbone.js,Javascript,Backbone.js,如果字段的值为0,我将尝试显示一个对话框弹出窗口。我可以做到这一点,但在渲染页面中,如果输入值为0且未更改,我将再次看到该对话框 如果渲染时输入值为0,则对话框不应存在 <input id="input-value" type="text" class="text-controll"/> //this model return values from attributeName from the backend 我认为主干网有代码来检查内置的: save() { var name
<input id="input-value" type="text" class="text-controll"/> //this model return values from attributeName from the backend
我认为主干网有代码来检查内置的:
save() {
var nameChanged = !!this.model.changedAttributes()['attributeName'];
if(nameChanged && this.model.get('attributeName') === 0) {
dialog.confirm(
"Are you sure you want to save the data"
)
}
}
如果您以一些非标准的方式初始化模型,例如创建一个空模型,然后从数据库中“更改”为值,则可能会失败。但对于标准用途,这应该是可行的
此处的文档:我也实现了同样的目标,您何时将输入值设置为model?你什么时候打电话给save?这里缺少很多细节。。。请看。。。
save() {
var nameChanged = !!this.model.changedAttributes()['attributeName'];
if(nameChanged && this.model.get('attributeName') === 0) {
dialog.confirm(
"Are you sure you want to save the data"
)
}
}