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
95
How to use delegated version of Jquery .on() with infragistics events
posted

The code below works.  The .on() function in JQuery is can attach the event.  However, if I replace the combo with AJAX, I have to attach again.  I would like to use the delegated version of the .on() function.  In this example, The commented out code does not work.  I also tried the delegate syntax that has been suggested elsewhere on this forum.  I am using JQuery 1.7.1 specifically for the .on() functionality, and I have verified it works on normal html events.  I am using 12.1 infragistics.  I placed the script at the end to show that the script is executing after the MVC helper is done.

 

@{
    var comboModel = new ComboModel {
        DataSource = new [] { "fee","fi", "fo","fum"},
        InputName = "TestCombo",
        ID = "TestComoboTarget"
       
    };
}

<div id="comboTestContainer">
@Html.Infragistics().Combo(comboModel)
</div>


<script type="text/javascript">

    $(document).ready(function () {

        //This code works
                        $('span#TestComoboTarget').on('igcomboselectionchanged', function () {
                            alert('hello');
                        });

        //This does not work
        //        $('div#comboTestContainer').on('igcomboselectionchanged', 'span#TestComoboTarget', function() {
        //            alert('hello');
        //        });

        //This also does not work
        //        $(document).delegate("span#TestComoboTarget", "igcomboselectionchanged",
        //            function (evt, ui) {
        //                alert('hello');
        //            });
    });

</script>