Results 1 to 2 of 2

Thread: questions about correct use MVC

  1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    51

    Default questions about correct use MVC

    Hello,

    i begin with MVC, i have 2 questions

    my app :
    view : i have a panel, inside i have a carousel and dockitem bottom with a button
    controller :
    Code:
    index: function(obj) {
            if(!this.panelCarousel)
    	{
    	        this.panelCarousel = this.render({
    		xtype : 'book-panelCarousel' 
    		});
    		
                    this.panelCarousel.query('#diapoButton')[0].on({
    			tap : this.showDiaporama,
    			scope : this
    		}) 
    					
    	}
    	
             this.application.viewport.setActiveItem(this.panelCarousel);
    	if(obj.nPage)this.goTo(obj.nPage)
    }, 
    
    goTo: function(number) {
    			 
               this.panelCarousel.carousel.setActiveItem(parseInt(number-1));
    
    },
    
    showDiaporama : function(btn, event){
    				
    	var txtHtml = '';
    	for (i=1;i<28;i++)txtHtml += '<img src="images/page-'+i+'.jpg" width="100" style="border:#ccc solid 1px;margin-right:5px" id="img_'+(i-1)+'" />';
    	this.diaporamaPanel = new Ext.Panel({
    		floating: true,
    		modal: true,
    		centered: false,
    		styleHtmlContent: true,
    	        width: Ext.is.Phone ? 260 : 400,
                    height: Ext.is.Phone ? 220 : 400,
    		scroll:'vertical',
    		html :'<div align="center">'+txtHtml+'</div>',
    	        dockedItems : [
    			{
    				xtype:'toolbar',
    				dock:'top',
    				title : "Diaporama"
    							  
    			}
    		],
    	         listeners : {
    			click: {
                			 element: 'el', //bind to the underlying el property on the panel
    				 fn: function(el){
                                          var tab = el.target.id.split("img_");
    				      var numPage = tab[1];	
    				      this.goTo(numPage)// <------- HERE MY PB, don't work
    				}
    			},
    			deactivate :function()
                            {
    				diaporamaPanel.destroy();	
    			}
    		}
    	})
    	this.diaporamaPanel.showBy(btn)
    				 
    }
    My question :
    is a good use to build my diaporamaPanel in my controler?
    i try to build it in another view call but how can i display it when we click on button ?

    second question :
    when my diaporamaPanel is show, i have a list of image and when we click one, i want to go to the good page but
    this.goTo don't work , problem of cibling but i don't find how make this

    thanks for your help, i hope your understand my english

  2. #2
    Sencha User
    Join Date
    Oct 2010
    Posts
    51

    Default

    hi,
    i found my pb
    i shoud add scope
    Code:
    listeners : {
    	click: {
                     element: 'el', //bind to the underlying el property on the panel
                     scope : this,
    		 fn: function(el){
                          var tab = el.target.id.split("img_");
    		      var numPage = tab[1];	
    		      this.goTo(numPage)// <------- now it works
    		}
    	},
    	deactivate :function()
            {
    		diaporamaPanel.destroy();	
    	}
    }
    but nobody have a idear if it's a good use to build my diaporamaPanel in my controler?

    i don't think so but I would appreciate your advice and guidance

    thanks

Similar Threads

  1. Is this the correct way to do this?
    By fge in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 7 Dec 2010, 12:49 PM
  2. 2.2.1 SDK. Is that the correct ext-all.js?
    By INeedADip in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 25 Mar 2009, 11:31 AM
  3. Am I doing this correct?
    By dlbjr in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 19 Jun 2008, 7:36 AM
  4. It's the correct way?
    By TheItalianJob in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 7 Feb 2008, 5:41 AM
  5. New User: Layout Questions, Property Questions
    By muffinman in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 25 Aug 2007, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •