View Full Version : Pass parameters in Controller function

22 Aug 2012, 10:06 PM
I have a controller code

Ext.define("Namespace.controller.Home", {
extend: 'Ext.app.Controller',
views : ['Home','Activity'],

config: {
refs: {
postButton: 'tabbar button[title=Activity]',
activityForm: '#activityForm',
commentPanel: '#commentPanel',
like: '#like'
control: {
'button[action=submitPost]': {
tap: 'submitActivityForm'
'tabbar button[title=Activity]': {
tap: 'clearBadgeText'
submitActivityForm: function() {
var form = this.getActivityForm();

I want to be able to pass a parameter to the submitActivity function every time the 'button[action=submitPost]' is clicked something like a counter keeping track of how many times the button was clicked. How do I pass a parmeter in controller within the refs?

23 Aug 2012, 2:34 AM
I found a workaround ... I was able to use the statics block to create a counter

statics: {
instanceCount: 0
submitActivityForm: function(){
var counter = this.self.instanceCount++;

This solved my problem

23 Aug 2012, 11:40 PM
Or you could do something like this, without statics:


24 Aug 2012, 12:13 AM
Perfect I like this solution much better than the statics. Very scalable and extensible.