Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch 在Sencha中查看加载事件处理程序?_Sencha Touch_Extjs_Sencha Touch 2 - Fatal编程技术网

Sencha touch 在Sencha中查看加载事件处理程序?

Sencha touch 在Sencha中查看加载事件处理程序?,sencha-touch,extjs,sencha-touch-2,Sencha Touch,Extjs,Sencha Touch 2,在我的sencha应用程序主页中,我有一个空列表。在应用程序统计时,我想从数据库中获取数据并将其添加到列表存储中。那么,是否有加载视图的侦听器。我使用的是MVC架构。我尝试了controller的“启动”和view的“痛苦”听众,但没有成功。我想要像jqm“pagebeforeshow”这样的东西,在这里我可以在显示页面之前进行数据库获取 $("#HomePage").live('pagebeforeshow',function(event, ui){ // fetch data and add

在我的sencha应用程序主页中,我有一个空列表。在应用程序统计时,我想从数据库中获取数据并将其添加到列表存储中。那么,是否有加载视图的侦听器。我使用的是MVC架构。我尝试了controller的“启动”和view的“痛苦”听众,但没有成功。我想要像jqm“pagebeforeshow”这样的东西,在这里我可以在显示页面之前进行数据库获取

$("#HomePage").live('pagebeforeshow',function(event, ui){
// fetch data and add to list   
});

如果您使用MVC架构,您可以在控制器操作中加载数据。查看sencha touch文档中的示例

Ext.define('MyApp.controller.Users'{
扩展:“Ext.app.Controller”,
配置:{
路线:{
'user/:id':'showUserById'
},
参考文献:{
main:“#mainTabPanel”
}
},
//加载用户,然后将“userprofile”视图添加到主选项卡面板
showUserById:函数(id){
MyApp.model.User.load(id{
范围:本,,
成功:功能(用户){
这是.getMain().add({
xtype:'userprofile',
用户:用户
});
}
});
}
});
1)您可以在视图中覆盖initialize方法

Ext.define('YourApp.view.YourView', {
    initialize: function () {
       var ctrl = YourApp.app.getController('YourController');
       ctrl.functionYouWantToCall();
}
但这不是一个好的MVC解决方案

2) 控制器的启动方法应该有效。它将在应用程序加载时激发。也许您忘记了将控制器添加到app.js的“controllers”属性中