Hybrid View

  1. #1
    Sencha User
    Join Date
    Jan 2011
    Posts
    6
    Vote Rating
    0
    lanlau is on a distinguished road

      0  

    Default Unanswered: Dynamic component event's doesn't fire the 2nd time

    Unanswered: Dynamic component event's doesn't fire the 2nd time


    Hi,

    i'm trying to implement dynamic component (view) creation and my problem is that the backbtn tap event fires correctly the first time but not the second time when the News view is recreated.

    could you please help me find what i'm missing?
    thanks a lot for your help

    here is my code :
    -app file: app.js
    Code:
    Ext.Loader.setConfig({enabled:true});
    Ext.application({
        name: 'myAPP',
    	controllers: ['Main']
    });
    - controller : main.js
    Code:
    Ext.define('myAPP.controller.Main', {
        extend: 'Ext.app.Controller',
    	
    	config: {
            profile: Ext.os.deviceType.toLowerCase()
        },
    	views:['Main','Home','News'],
    	
        refs:[
    		{ref: 'Main',selector: 'Main',autoCreate: true},
    		{ref: 'News',selector: 'News'},
    		{ref: 'Home',selector: 'Home'},	
    		{ref: 'newsBtn',selector: '#newsBtn'},
    		{ref: 'backBtn',selector: '#backBtn'}
    	],
        init: function() {
    		this.getMainView().create();
            this.control({
                '#newsBtn': {
                    tap: this.onNewsBtnTap
                },
    			'News #backBtn':{
    				tap: this.onBackBtnTap
    			}
            });
        },
    	onNewsBtnTap:function(){
    		var main=this.getMain();
    		var news=Ext.create('myAPP.view.News');
    		var home=this.getHome();
    		main.setActiveItem(news);
    	},
    	
    	onBackBtnTap:function(){
    		var main=this.getMain();
    		var home=this.getHome();
    		var news=this.getNews();
    		
    		main.setActiveItem(home);
    		news.remove();
    
    
    	}
    });
    - main view: Main.js
    Code:
    Ext.define('myAPP.view.Main', {
    	extend: 'Ext.Container',
    	alias:'widget.Main',
    	xtype:'Main',
    	requires: [
    		'Ext.NavigationBar'
    	],
    	config:  {
    		fullscreen: true,
    		layout    : {
    			type: 'card',
    			animation: {
    				type: 'slide',
    				direction: 'left',
    				duration: 250
    			}
    		},
    		
    		items: [
    			{
    				xtype:'Home',
    			}
    		]
    	} 
    });
    - Home view : Home.js
    Code:
    Ext.define('myAPP.view.Home', {
        extend: 'Ext.Container',
    	require:[
    	'Ext.Img'
    	],
    	alias:'widget.Home',
    	//xtype:'Home',
        config: {
    		style:"background:white",
            layout: {
                type : 'vbox',
                pack : 'center',
                align: 'center'
            },
            cls   : 'card1',
            //scrollable: 'vertical',
            defaults: {
                xtype: 'container',
                height:110,
                layout: {
                    type : 'hbox',
                    align: 'bottom',
    
    
                },
                defaults: {
                    xtype : 'button',
                    flex  : 1,
                    margin: 5,
                }
            },
            items: [
    			{
    				html:"<img src='resources/img/parkerlegris.jpg'/>",		
    			},
                {
                    items: [
    				    {ui: 'round small', text: 'News',height:100,width:90,id:'newsBtn'},
                        {ui: 'round small', text: 'Products',height:100,width:90},
                        {ui: 'round small', text: 'Downloadings',height:100,width:90,iconCls:'bookmarks',iconMask:true}		
                    ]
                },
    			{
                    items: [
                        {ui: 'round small', text: 'Tools',height:100,width:90},
                        {ui: 'round small', text: 'Contact',height:100,width:90,iconCls:'team',iconMask:true},
                        {ui: 'round small', text: 'Settings',height:100,width:90,iconCls: 'settings',iconMask:true}			
                    ]			
    			}
            ]
        }
    });
    - News view: News.js
    Code:
    Ext.define('myAPP.view.News', {
        extend: 'Ext.Panel',
    	alias:'widget.News',
    	fullscreen:true,
    	config:
    	{
    			
    			layout:{
    				type:'vbox',
    				align:'stretch'
    			},
    			defaults:{flex:1},
    			items:[
    					Ext.create('Ext.Carousel', {
    								defaults: {
    									cls: 'card'
    								},
    								items: [{
    									html: '<h1>Carousel</h1><p>Navigate the two carousels on this page by swiping left/right or clicking on one side of the circle indicators below.</p>'
    								}, {
    									html: '2'
    								}, {
    									html: '3'
    								}, {
    									html: '4'
    								}, {
    									html: '5'
    								}, {
    									html: '6'
    								}]
    							}),
    					{
    						id: 'mainNavigationBar',
    						xtype : 'navigationbar',
    						docked: 'top',
    						title : 'News',
    						ui:'light',
    						items: [{
    							xtype : 'button',
    							id: 'backBtn',
    							hidden: false,
    							align : 'left',
    							ui    : 'back',
    							text  : 'Back'
    						}]
    					}
    			]
    	}
    
    
    
    
    	
    });

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Answers
    148
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Hi lanlau.
    Your problem seems to be that you are calling the remove function directly on your news view.
    So let me to suggest you something:

    First. since you define the news alias as "widget.News", I suggest you to use the shortcut Ext.widget to create the News view, so:

    Code:
    var main=this.getMain();
    var news=Ext.widget('News');
    var home=this.getHome();
    main.setActiveItem(news);
    Then, from your "onBackBtnTap" just change the "news.remove" with

    Code:
    main.remove(news, true);
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  3. #3
    Sencha User
    Join Date
    Jan 2011
    Posts
    6
    Vote Rating
    0
    lanlau is on a distinguished road

      0  

    Default


    thanks for your reply.
    in fact my problem is still persisting. i'm not sure i was enough clear but here is the test scenario :

    Home page loads,
    click on news button,
    on the news page click on back btn,
    i'm back to the home page,
    i click 1 more time on the news button
    the news view is correctly displayed but when i click on the back btn nothing happens....

    it seems i've lost the listeners on the backbtn tap event.

  4. #4
    Sencha User
    Join Date
    Apr 2013
    Posts
    25
    Vote Rating
    0
    JairoDiens is on a distinguished road

      0  

    Default


    I have the same problem, Can you help me.

    thanks

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi