1

I am trying to get all date time of the page and replace it with jquery date time picker.

the reason I am trying to handle it with jquery is: I don't want to ask all developer to change their code and replace it with new component hence jquery will replace the date time with a custom DateTime picker and trigger change event of the component to update model ,

what I did

found all input with date type in my page with the following code :

 $("input[type=date]").each(function () {

// Add picker to input parrent i will hide the current input , i will fill it in the picker change value 

 $(this).parent().append("<input readonly='readonly'  palceholder='" + dateFormat + "'  class='pickerJquery " + objClass + "' style='" + style + " ; height:31px !important ; z-index: 100000' type='text' />");


 $(".pickerJquery").datepicker({
          onSelect: function (dateText, inst) {
            const date = $(this).datepicker('getDate');            
            // set value here 
            $(field).val(value);

            // Trying to call the model change of angular ****** this part not works
              $(field).trigger("click");
              $(field).trigger("dblclick");
              $(field).trigger('input');
              $(field).trigger('change');

          }

        });


});

the issue: model not updated after setting the value with jquery and trigger click / dbclick / input / change ...

Any idea?

farham heidari
  • 157
  • 2
  • 9
  • Have you tried below? https://stackoverflow.com/questions/37844092/how-do-i-programmatically-set-an-angular-2-form-control-to-dirty – Mehdi Apr 25 '19 at 03:30

1 Answers1

-1

Talk to Dileep or check the datatable component, I think its the same.