English 中文(简体)
Refreshing the screen while card switch in sencha touch
原标题:

I have a screen where the formBase contains all of the dynamically created UI controls. I am using card layout and switching between views. Now it so happened that I have to execute the formBase for each time the card switches (I mean for each time my screen appears).

I have used the beforeshow listeners for form to achieve that. But its not working. Below is my code.

var formBase = new Ext.form.FormPanel({
        scroll:  vertical ,
        ui:  round ,
        items: [fieldSet, {
            xtype :  fieldset ,
            items : [ item1, item2, item3]
            ]
        }],
         listeners: {
            beforerender: function(ele) {
               console.log(" Screen before render");
               initScreenComps()
            },

            beforeshow: function(ele) {
                console.log(" screen before show");

            }
        }
    });

Edit:1

I have a viewport.js file, where i have reveal method to change the viewport. here is the below code of Viewport.js. Still it has no effect. pls suggest.

MyApp.views.Viewport = Ext.extend(Ext.Panel, {
    fullscreen: true,
    layout:  card ,
    initComponent: function() {
        Ext.apply(this, {

            items: [
                { xtype:  MyApp.views.view1 , id:  view1  },
                { xtype:  MyApp.views.view2 , id:  view2  },
                { xtype:  MyApp.views.view3 , id:  view3  },
                { xtype:  MyApp.views.view4 , id:  view4  },
                { xtype:  MyApp.views.view5 , id:  view5  }             
            ],
        listeners:{
           beforecardswitch:function(newCard, oldCard, index, animated){
                 //do something...
               console.log(" Card switched"  + " New " + newCard + " OLD : " + oldCard + " index + " index);
           }
        }
        }
        );
        MyApp.views.Viewport.superclass.initComponent.apply(this, arguments);
    },

    // used for changing view port of application
    reveal: function(target) {      
        this.setActiveItem(MyApp.views[target],{ type:  slide , direction:  right  }
        );
    }
});

And now i am calling view2 from the controller, on button click event.

MyApp.views.viewport.reveal( view2 );
最佳回答

I think, it will be best if you use "beforeactivate" or "activate" event listeners for it. These events get fired whenever the card layout sets this item as the active item. So, the code will be like this:

var formBase = new Ext.form.FormPanel({
        scroll:  vertical ,
        ui:  round ,
        items: [fieldSet, {
            xtype :  fieldset ,
            items : [ item1, item2, item3]
            ]
        }],
         listeners: {
            beforeactivate: function(panel) {
               console.log(" Screen before render");
               initScreenComps()
            }
        }
    });
问题回答

You should listen for beforecardswitch event instead. for example

listeners:{
   beforecardswitch:function(newCard, oldCard, index, animated){
 //do something...
   }
}




相关问题
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? ...

热门标签