View Full Version : Controller applies control ComponentQuery before UI components created?

27 Apr 2012, 6:33 AM
The way I am understanding the Sencha code is that component queries for a Controller's control events are applied when the Controller is initialized, which would seem to happen before the UI components are created. If that's the case, then how would control events ever attach to anything?

Here is my sample code, whereby the tap event in control never fires. I commented out in the controller launch method an explicit event listener attachment. If you de-comment it, the tap event will fire.

<!DOCTYPE html>
<title>Sencha Test</title>

<script type="text/javascript" src="sencha-touch-all-debug.js"></script>
<link href="sencha-touch.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

Ext.define('Test.view.LoginForm', {
extend: 'Ext.form.Panel',
alias: 'widget.loginform',

config: {

fullscreen: true,

layout: 'vbox',
submitOnAction: false,
scrollable: false,
padding: 18,

items: [{
xtype: 'component',
cls: 'open-login',
style: 'font-size:12px;font-weight:bold',
tpl: [
'<div style="float:left;margin-top:8px;margin-right:10px">Log in using:</div>',
'<tpl for="providers">',
'<div class="providerlink" style="float:left;margin-left:5px">',
'<img class="{.}" src="http://www.fareclock.com/static/site/images/icons/{.}-icon.png" style="width:46px;height:46px">',
data: {
providers: ['google', 'yahoo']

Ext.define('Test.controller.Main', {
extend: 'Ext.app.Controller',
requires: [

config: {

refs: {

openLogin: 'loginform component[cls=open-login]'

control: {

openLogin: {
tap: 'doSignInProvider'

doSignInProvider: function(e, t){

var target = e.getTarget('div.providerlink img');

//wasn't tapped on the img
if (!target) {

var provider = t.className;

launch: function(){

var openLogin = this.getOpenLogin();
if(openLogin && openLogin.rendered){
//openLogin.element.on('tap', 'doSignInProvider', this);

name: 'Test',

views: ['LoginForm'],
models: [],
stores: [],
controllers: ['Main'],

launch: function() {

// probably desktop browser, so simulate iPhone layout
Ext.Viewport.setMargin(50); // leave a little space in dom around the viewport



27 Apr 2012, 7:44 AM
I figured out that the Controller's control events are for Component events only. They do not function on Element events.