View Full Version : controller action fires on all button clicks

11 Apr 2014, 8:26 AM
Hello, after doing ext js 3.4 for a few years I am starting Ext JS 4. I am writing a new application and have run into an odd issue. I have created a controller that has a controller action which is tied to a button click. So every time I click a button I have a function that is executed. My issue is that every time I click any button (including tabs), my function is executed. I specified the specific button I wanted this function tied to in the targetType field of the Config panel in archetict. I am sure I am making a nooby mistake, I just do not know where.

My code is below, any ideas are most appreciated.

Ext.define('DPM.controller.searchPartyButtonClick', {
extend: 'Ext.app.Controller',
views: ['PartySearchButton'],
buttonClick: function (button, e, eOpts) {
var firstName = Ext.ComponentQuery.query('#firstNameField')[0].getValue();
var middleName = Ext.ComponentQuery.query('#middleNameField')[0].getValue();
var lastName = Ext.ComponentQuery.query('#lastNameField')[0].getValue();
var address = Ext.ComponentQuery.query('#address1Field')[0].getValue();
var city = Ext.ComponentQuery.query('#cityField')[0].getValue();
url: 'http://localhost:8080/DuplicatePartyManagement/servlet/searchParties',
method: 'POST',
headers: {
'Content-Type': 'application/json'
jsonData: {
firstName: firstName,
lastName: lastName
success: function (response, opts) {
var obj = Ext.decode(response.responseText);
failure: function (response, opts) {}
init: function (application) {
"button": {
click: this.buttonClick

sorry the code is all on one line, not sure why it would not format correctly

Scott Mildenberger
11 Apr 2014, 12:17 PM
Hard to read the code but looking at one of my apps in the config of the function I have the 'controlQuery' set to #save where my button has an itemid of 'save'. Maybe you are missing that? My targetType is Ext.button.Button.

11 Apr 2014, 12:36 PM
That was it! I had my controlQuery set to 'button' so the function was associated to every button in my application. I changed the controlQuery to be my buttons's itemId '#searchButton' and now it works great. Good call, thanks for the reply.