-
19 Mar 2012 6:00 AM #1
Answered: Button tap event not firing
Answered: Button tap event not firing
Hey guys, I have been trying to listen for a button click in a view form my controller to no avail. Just wondering if I should setup a listener in the view to fire and event for the controller or if there is a better option. I am trying to keep all my functions and listeners in my controller.
My Controller:
The button comes from a template which I have stored as a string in a global template file.PHP Code:Ext.define('Controllers.PublicationsController', {
extend: 'Ext.app.Controller',
config: {
control:{
PublicationsContent : {
painted : 'loadPublicationsContent'
},
BrowseByTopic:{
tap : 'loadBrowseByTopic'
}
},
refs: {
PublicationsContent: '#publicationsContent',
PublicationsPage: '#publicationsPage',
BrowseByTopic: 'button[browseByTopic]'
},
},
init: function(options)
{
this.callParent(arguments);
console.log('PublicationsController:init');
},
loadPublicationsContent:function()
{
console.log('loadPublicationsContent:init');
var template = new Ext.Template(app.util.Templates.config.publications,{compiled: true});
this.getPublicationsPage().setHtml(template.html);
},
loadBrowseByTopic:function()
{
console.log(this,'clicked::loadBrowseByTopic');
},
loadSearchByTag:function()
{
console.log(this,'clicked::loadSearchByTag');
}
});
My View:
Thanks for any help you might have!!PHP Code:Ext.define('Views.publications', {
extend: 'Ext.Panel',
xtype: 'publicationsView',
id: 'publicationsPage',
config: {
styleHtmlContent: true,
scrollable: 'vertical',
items:[
{
docked: 'top',
xtype: 'toolbar',
title: 'Publications',
cls:'panel_title'
},{
xtype: 'panel',
id: 'publicationsContent',
defaults: {
styleHtmlContent: true
},
},
],
},
initialize: function() {
this.callParent(arguments);
console.log('publicationsView:init');
},
});
-
Best Answer Posted by mitchellsimoens
A ST2 button and a HTML button are two different things and will not behave the same. refs and control configs use ComponentQuery which is trying to look for a ST2 button but you have a HTML button and is not able to be listened to.
-
19 Mar 2012 10:18 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,640
- Vote Rating
- 435
- Answers
- 3106
A ST2 button and a HTML button are two different things and will not behave the same. refs and control configs use ComponentQuery which is trying to look for a ST2 button but you have a HTML button and is not able to be listened to.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Mar 2012 5:58 AM #3
Whats the best way
Whats the best way
To insert a ST2 button into a html element?
These do not work:
I am assuming it's the same issue as before, I am not dealing with a component but a html div.Code:var button = Ext.create('Ext.Button', { text: 'Button' }); Ext.fly('publications_search_choice').update(button); var button = Ext.create('Ext.Button', { text: 'Button' }); Ext.fly('publications_search_choice').add(button); var button = Ext.create('Ext.Button', { text: 'Button' }); Ext.fly('publications_search_choice').setHtml(button);
Thanks again for your help.


Reply With Quote