Question

I need to manually make call to .change() to do some operation and i have written an .on() for this functionality for other input controls. But for DatePicker column i need to fire it manually as it's not firing whenever date is set to textbox.

$('input.JDateCtrl').datepicker({        
        onSelect: function (dateText) {
        debugger;
        //$(this).parent().find('input[type=text]').val(dateText);
        $(this).parent().find('input[type=text]').attr('value', dateText);
        var ctrlID = $(this).parent().find('input[type=text]').attr('id');
        $('#' + ctrlID).trigger('change');
       // $('#' + ctrlID).change(); // Tried it too
    }
 });

And .on() is as below.

  $jQuery(document).on('change', '.JAsyncUpdateTxt', function () {
       // Some Operations being performed in this block
   });

But .on() is not firing whenever i make trigger change event.

P.S : its already wrapped inside $jQuery(document).ready();

Was it helpful?

Solution

$(document).on('change', '.JAsyncUpdateTxt', function () {
       // Some Operations being performed in this block
   });

Remove 'jQuery'. Use any one.

OTHER TIPS

Please put your .on() first then .datepicker as below:-

$(document).on('change', '.JAsyncUpdateTxt', function () {
   // Some Operations being performed in this block
});


$('input.JDateCtrl').datepicker({        
    onSelect: function (dateText) {
    debugger;
    //$(this).parent().find('input[type=text]').val(dateText);
    $(this).parent().find('input[type=text]').attr('value', dateText);
    var ctrlID = $(this).parent().find('input[type=text]').attr('id');
    $('#' + ctrlID).trigger('change');
   // $('#' + ctrlID).change(); // Tried it too
}
});

I think this can help you.

  $(document).on('change', '.JAsyncUpdateTxt', function () {
       // Some Operations being performed in this block
   });

remove jquery use one either jquery or $

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top