我的应用程序中有多个页面,其中一个是添加驱动程序信息。
当我去添加驱动程序信息页面并填写一些字段,如"驱动程序许可证"文本框,然后我不将其添加到数据库并单击"返回"按钮(放弃更改并返回主页)当我再次进入此页面时,我之前填入数据的字段不会清除和刷新(它应该清除所有字段并且为空)
有人有解决方案吗?
代码"返回按钮:
app.datasources.driver.clearChanges(function() {
console.log("cleared changes");
});
returnToDriver();
returnToDriver()代码是:
app.datasources.DRIVERS_LIST.query.clearFilters();
app.datasources.DRIVERS_LIST.load();
app.showPage(app.pages.Driver);
已经尝试过:
widget.root.descendants.TextBox1.value = "";
widget.root.descendants.TextBox1.value = null;
但不适合我。
此致
答案 0 :(得分:0)
可能有多种方式离开页面:
处理所有可能的导航方案的最佳方法是使用onDetach
页面事件
// Implicit way
// page onDetach event handler, assuming that page
// is bound to appropriate datasource:
// @datasources.<MyDatasource>.modes.create
widget.datasource.clearChanges();
// Explicit way
// Explicitly clearing changes for create datasources in
// page onDetach event handler
app.datasources.<MyDatasource1>.modes.create.clearChanges();
app.datasources.<MyDatasource2>.modes.create.clearChanges();
...
将此代码添加到onDetach
页面的事件处理程序后,您可以从页面中删除所有其他clearChanges
次出现。