PDA

View Full Version : questions about correct use MVC



tonin10
11 Mar 2011, 5:28 AM
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 :


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

tonin10
12 Mar 2011, 6:30 AM
hi,
i found my pb
i shoud add scope


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