-
21 Dec 2012 5:51 AM #1
Unanswered: Controller problems: Argh !
Unanswered: Controller problems: Argh !
Hello everyone,
I'm pretty new to Sencha Touch (and ext js really). So this is probably a noob-ish question and/or a silly mistake.
I'm trying to call my controller on the tap of a button in a view.
Here is my view code :
Code:Ext.define("documind.view.Search", { extend: 'Ext.tab.Panel', alias: 'viewSearch', requires:[ 'Ext.TitleBar', 'Ext.form.*', 'Ext.field.*', 'Ext.Button' ], config: { tabBarPosition: 'bottom', ui: 'light', activeTab: 1, defaults: { scrollable: true, layout: { align: 'middle', type: 'hbox' }, }, items: [ { xtype:'container', title:'Home', iconCls: 'home', flex: 1, layout: { align: 'center', type: 'vbox' }, fullscreen: true, items:[ { //Row 1 items:[ { xtype: 'button', id: 'rcSearch', text: rcSearch, iconCls:'search', margin: 5, iconMask:true, }] }] }] } });
And my controller :
Am I not meant to call the id of my component in the controller ? viewSearch > rcSearch --> then the function I need ?Code:Ext.define('documind.controller.searchController', { id: 'searchController', alias: 'searchController', extend : 'Ext.app.Controller', config : { refs: { searchView: 'viewSearch', }, control : { searchView : { '#rcSearch' : { select : 'searchEvent' } } } }, searchEvent: function(){ alert('Search'); } });
I'm so confused !
-
21 Dec 2012 5:54 AM #2
Try this:
and use itemId instead of if on your button. See if that works.Code:config : { refs: { searchView: 'viewSearch', }, control : { searchView : { '#rcSearch' : { tap : 'searchEvent' } } } },
-
21 Dec 2012 6:00 AM #3
Thanks
Thanks
Thank you for your quick reply, but neither work

I had already tried 'tap' and then thought that select might work but nada !
But it doesn't generate an error, I can't figure it out
Any another ideas ?
Thank you again
Sarah
-
21 Dec 2012 6:07 AM #4
Sorry I made a typo, I meant to say change your button 'id' to 'itemId'.
-
21 Dec 2012 6:11 AM #5
Also, in your view, set its alias to:
Code:alias: 'widget.viewSearch'
-
21 Dec 2012 6:14 AM #6
Tried
Tried
I've also tried that. Doesn't seem to work.
On tap on the button, nothing happens at all.
So it should be this :
and in the controller :Code:itemId: 'rcSearch'
Code:control : { searchView : { '#rcSearch' : { tap : 'searchEvent' } }
So that means I'm doing something wrong somewhere else ?
-
21 Dec 2012 7:04 AM #7
Ohh, well I do event firing differently. I use the method in this video: http://docs.sencha.com/touch/2-1/#!/...etting_started
If you're still struggling with your method, use the one in the vid.


Reply With Quote