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>

Parents
  • 95
    posted

    Also,

    Just to show I am reading the documentation, this page says that on() is supported and preferred to the delegate syntax in JQuery 1.7:

    http://help.infragistics.com/NetAdvantage/jQuery/2012.1/CLR4.0?page=Using_Events_in_NetAdvantage_for_jQuery.html

    However, no examples of on() syntax are given.  The code samples show live() and die().  In the event page for igcombo, the delegate syntax is shown, but that does not seem to work in JQuery 1.7.

    For grins, I tried this in the above example:

                    $(document).on('igcomboselectionchanged', 'span#TestComoboTarget', function() {
                        alert('hello');
                    });

    No, luck.

Reply Children