Titanium:如何在聚焦时重新加载选项卡?
我在我的应用程序中构建了一个收藏选项卡,用于显示数据库中标记为此类的条目。在背面,这可以正常工作,但我不知道如何在更改后重新加载“收藏夹”选项卡。当我退出并重新启动应用程序时,更新会按预期显示。
本质上,我遇到了与这里提出的相同的问题: http: //developer.appcelerator.com/question/31211/tab---tableview--database-reload
<块引用>“我的应用程序中有一个“搜索”和“搜索历史记录”选项卡。在此选项卡下执行的每个搜索都会插入到我的本地数据库中。 但是,当我在搜索后浏览到“搜索历史记录”选项卡时,新的搜索并未反映在从数据库检索数据的表格视图中。 然而,当我退出应用程序并重新启动它时,会加载最新的搜索。 我需要一些帮助来弄清楚如何在不退出应用程序的情况下触发表格视图重新加载。 解决方案更新: 我觉得问这个问题很“菜鸟”,但它真的很简单 我为包含选项卡的窗口添加了一个“焦点”事件监听器来加载数据。 win.addEventListener('focus', function() { loadDBdata(); });
这看起来很合理,但是 loadDBdata 函数应该包含什么内容? 我将非常感谢任何对此的指示。
I have built a favorite-tab in my application that displays entries in a database that are flagged as such. On the backside this works as it should, but I can't figure out how to reload the favorites tab after changes have been made. When I quit and relaunch the app though, the updates appear as they should.
In essence I have the same problem as is presented here: http://developer.appcelerator.com/question/31211/tab---tableview--database-reload
"I have a 'search' and 'search history' tab in my application. Every search executed under this tab gets inserted into my local db.
However the new search is not reflected in the tableview retrieving data from the DB in the 'search history' tab when i browse to it, after searching.
The latest search, however, gets loaded when I exit the app and relaunch it.
I need some help in figuring out how to trigger the tableview reload without exiting the app.
SOLUTION UPDATE:
I feel 'noobish' for asking this question but it was really so simple
I added a 'focus' eventlistener for the window housing the tab to load the data.
win.addEventListener('focus', function() { loadDBdata(); });
This seems reasonable, but what should the loadDBdata function should contain?
I would greatly appreciate any pointers to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议在更新收藏夹时触发一个事件,并在保存收藏夹列表的桌子上放置一个事件侦听器。当它收到事件时,它应该更新表内容。
看到这个问题我刚刚回答它应该提供解决您的问题的指南
Appcelerator 中页面刷新功能出现问题
i would suggest firing an event when the favorites are updated and having an event listenter on the table that holds the favorites list. When it receives the event, it should update the tables contents.
see this question I just answered it should provide a guide for solving your problem also
Problems with refresh function for page, in Appcelerator
loaddb 函数应包含以下内容:
the loaddb function should contain something like: