PDA

View Full Version : Problem with this.control in controller



tino7_03
4 Dec 2011, 8:26 AM
Dear,
I'm trying to create my first ST2 application after a good ST1 experience.
This is a part of my app:

controller/Main.js

Ext.define(
'GpMobile.controller.Main', {

extend:
'Ext.app.Controller',

views: [
'Domain','Login'],

stores: [
'Settings'],

config: {

profile: Ext.os.deviceType.toLowerCase()

},

init:
function() {


if(this.getSettingsStore().getCount()==0){

Ext.Viewport.add({xtype:
'domainview'});

}


else{

Ext.Viewport.add({xtype:
'loginview'});

}


this.control({


'button[go]': {

tap:
function() {

Ext.Viewport.add({

xtype:
'loginview'

});

}

}

})




});


view/Domain.js


Ext.define(
'GpMobile.view.Domain', {


extend:
'Ext.Panel',

alias:
'widget.domainview',

config: {

fullscreen :
true,


//itemId:"pippo",

layout: {

type:
'vbox',

pack:
'top'

},

items: [


new Ext.NavigationBar({

dock :
'top',

ui:
'dark',

title: gblAppName,

items: [

{

xtype:
"button",

id:
'btnDomainLogoff',

name:
"btnDomainLogoff",

ui :
"round",

text:
"Logoff",

align:
'left'

}

]

}),


new Ext.NavigationBar({

dock :
'top',

ui:
'light',

title:
'Accesso ai dati',

items: [

{

xtype:
"button",

id:
'btnDomainBack',

name:
"btnDomainBack",

ui :
"back",

text:
"Indietro",

align:
'left'

},

{

xtype:
"button",

id:
"btnDomainDone",

name:
"btnDomainDone",

ui :
"forward",

text:
"Prosegui",

align:
'right',

go:
'loginview'

}

]

}),



{

xtype:
'container',

layout: {

type:
'vbox',

pack:
'center'

},

items:[

{

xtype:
'fieldset',

instructions:
"Specificare il dominio del server per l'accesso ai dati",

items: [

{

xtype:
'textfield',

name :
'txtDomain',

label:
'Dominio',

labelWidth:
'10%',

placeHolder:
"http://xxxxxxxxxxxx.xxx/"

}

]

}

]

}



]

}




 

});


App.js


Ext.Loader.setConfig({ enabled:
true});


Ext.application({


//phoneStartupScreen: 'images/sencha_logo.png',

name:
'GpMobile',

controllers: [
'Main'] ,


//autoCreateViewport:true

});


From two days I try to understand why my "this.control" in main.js not fire when I press button in domain.js. Same problem if I put a "render" listener into it like this:


'domainview'
: {

render:
function() {

alert(
'f');

}


Can you help me please?
Thanks in advance.

tino7_03
4 Dec 2011, 8:48 PM
SOLVED!


init:
function() {


if(this.getSettingsStore().getCount()==0){

Ext.Viewport.setActiveItem({xtype:
'domainview'});

}


else{

Ext.Viewport.setActiveItem({xtype:
'loginview'});

}


this.control({


/*'#btnDomainDone[go]':{ // Intercetta gli eventi del pulsante btnDomainDone

tap:function(){

alert('o');

}

},*/


'button[go]': { // Intercetta gli eventi di tutti i "button" con proprietà "go"

tap:
function(btn) {

Ext.Viewport.setActiveItem({xtype: btn.go});

}

}

})

}