Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
505
selectionChanged event is not fired when set selectedIndex
posted

Hi,

 

I am using igCombo in an ASP.NET MVC3 project, I found that the selectionChanged event is not fired when set selectedIndex. 

 

I used it like:

 

$("#comboCompanies").igCombo(
            {
                selectionChanged: function (evt, ui) {
                    var selectedId = ui.items[0].value;
                    DoSomething();
                }
            });

 

$("#comboCompanies").igCombo("selectedIndex", 2);

 


If the selection is made by the UI (I mean select option with mouse click), the selectionChanged will be fired.
But if I set the selection in code, the event won't be fired. Why?

 

  • 2735
    Verified Answer
    posted

    Hi, Jason,

    You have to bind events in ASP.NET in this way:

     

    $("#combo").igCombo({

                        dataSource: colors,

                        textKey: "Name",

                        valueKey: "Name",

                        width: "200px",

                        autoComplete: true

                  });

     

     

    $(document).delegate("#combo", "igcomboselectionchanged", function (evt, ui) {

                        var selectedId = ui.items[0];

                        console.log(selectedId.value);

    });

     

     

    In order to trigger this event you have to set third parameter fire to true $("#combo").igCombo("selectedIndex", 2, true);

    Related topics:

    http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=igCombo_Configure_Selection.html

    http://help.infragistics.com/jQuery/2012.1/ui.igCombo#!methods

    Regards,

    Stanimir Todorov