1
votes

I have a combo box . This listens to 'select' event. I trigger a custom event in the select event callback. This event is being fired twice when ever there is a change.

I have a similar combo box connected to the same controller but only one event gets fired from it.

I am using ExtJs 5.

Here is my code.

    {
        xtype: 'combobox',
        width: 150,
        textAlign: 'left',
        store: {
            fields: ['text', 'value'],
            data: [
                {"text": "a", "value": "a"},
                {"text": "b", "value": "b"},
               ]
        },
        allowBlank: false,
        editable: false,
        displayField: 'text',
        valueField: 'value',
        listeners: {
            select: function (combo, records) {
                console.log('comboooo ---------------- ', records[0].data.value);
                this.fireEvent('custom-event', 'key', records[0].data.value);
            },
            afterrender: function (cmp) {
                cmp.setSelection(1);
            }
        }
    }

Edit : Here is what it is going in my application.

I have a MainViewcontroller , MainView and SubView . SubView is a component inside the MainView.

I have two components each in SubView and MainView. I am adding the SubView after the MainView is added.

I am firing a custom event from 'change' event of a component of MainView. The MainController is able to recognize this. This event occurred only once as expected.

Now when i fire the same custom event from 'change' event of a component of SubView this event is getting fired twice

1
If you're using Ext 5, why did you tag your question with 4.1 & 4.2?Evan Trimboli
from the google responses i observed that there are not many ExtJS 5 results. So i thought tagging 4.1 and 4.2 along with 5 would be giving me quicker responsesphani
I created a fiddle and wasn't able to replicate the issue. The custom event only fires once. Can you provide more context/code or better, create a fiddle demonstrating the issue?weeksdev
i am not sure how to create a fiddle to replicate the issue. I kind-of understood the issue just now. let me edit the question to give you more information on what is going inside my application.phani

1 Answers

2
votes

I figured it out ...

The subView and the MainView both have their controller config referring to the main controller.

Since the subView is already a part of the MainView i need not register the controller here again.

I removed the controller config in the SubView and now it is working as expected.

Thanks for your time @weeksdev :)