English 中文(简体)
Sencha触摸 2中的小组活动流量
原标题:events flow of Panel in sencha touch 2

这是我的应用结构。

var loginView = Ext.create( Ext.Panel ,{
    id:  LoginView ,
    .....
});
var homeView = Ext.create( Ext.TabPanel ,{
    id:  HomeView ,
    items: [
           {
                xtype:  list ,
                title:  Home ,
                store: Ext.create( TweetStore ),
                disableSelection: true,
                ....
            },
            {
                title:  Reply ,
                ....
            },
            {
                title:  DM ,
                ....
            }
    ]
});
var mainView = Ext.create( Ext.Panel ,{
    id:  MainView ,
    layout:  card ,
    items: [ loginView, mainView ]
});
Ext.define( TweetStore , {
        extend:  Ext.data.Store ,
        config: {
            fields: ...
            pageSize: 25,
            autoLoad: true,
            proxy: {
                type:  ajax ,
                url:  /home ,
                pageParam:  page ,
                limitParam:  count ,
                reader: {
                    type:  json 
                }
            }
        }
    });

MainView 有两个面板。 LoginView 是用户输入用户名和密码的登录页。授权成功时,第二个面板 HomeView 会显示 。

我的问题:

  1. I want the data in TweetStore to be loaded after the authorization, that is, when the HomeView shows, the data begins to load. But the show event is triggered even the panel is still hidden. What event should I catch.
  2. When the application starts, I want to send a ajax request to check whether the user is login, if true, the LoginView hide and the HomeView shows. In which event should I check this?
最佳回答

问题1,您应该倾听 painted () 事件。

Fires whenever this Component actually becomes visible (painted) on the screen. This is useful when you need to perform read operations on the DOM element, i.e: calculating natural sizes and positioning.

Q.2) 在 初始化() 事件上发送用户认证请求。

组件初始化时的火灾

问题回答

<强度>-第一个问题:

painted 事件似乎不错,但实际上,根据我的经验,它目前释放的Sencha Touch 2中充满了臭虫。不要依赖它的存在和文件。

根据您所描述的, 很明显, 您想要在特定事件( 授权) 后上载您的商店, 那么在事件后启动自定义事件如何? 例如 :

loginForm.fireEvent(经认证的,此处) (或任何需要的额外参数)

然后,在您的控制器中,只需在 loginForm 视图中聆听事件 经认证的

<强度>-第二个问题:

正如您所说的, 您想要在应用程序启动后立即运行一些进程。 因此, 设置您的代码的正确位置是在您的 < code> app. js 函数中的 < code > launch () 函数中。 简单即可 。





相关问题
Windows 7 multitouch capabilities with HTML5

I have a problem: There are HTML5/CSS3 mobile frameworks on the market like Sencha Touch and Phonegap which can use the multi-touch gestures of the iPad/iPhone, Android, etc. That s working fine, I ...

Getting started with Sencha Touch

I m an Ext veteran but have a few rather simple mobile apps i need to create and naturally i m looking at sencha touch. Ting is - most of the examples don t run up in Firefox/Opera. I m happily using ...

Custom icon in TabPanel fails

I m trying to add a custom icon to a TabPanel but when I do that it just shows a dark box with rounded corners. My css looks like this: http://pastebin.org/447682 The code in the url is base64 for ...

Sencha Touch and ExtJS

Sencha Touch looks impressive, and ExtJS looks nice. I am evaluating if I should use ExtJS or SproutCore for an upcoming app. Now that Sencha Touch is in the mix, I wonder if I choose ExtJS, it d be ...

Turning Sencha Touch-based app into a true native iPhone app?

As I understand, Sencha Touch is just a javascript library that lets you create websites that respond to multitouch and other features you find in native iPhone apps. So... Your end result is accessed ...

Is anyone using Sencha Touch for mobile development?

We re evaluating Sencha Touch for mobile development. Has anyone used this yet (I realize that it s still in beta), and if so, what are its strengths / weaknesses? How does it compare to alternatives? ...

热门标签