Add add on change event listener via jQuery

As the title says, I'm trying to add an event listener via jQuery to a date picker. 

I stumbled upon this thread (How to write select function in datepicker | ASP.NET Core Forums | Syncfusion) but in requires the use of the change="" property.

I've already tried $('#DatePicker').on('change',()=>{}). It does fire when the date is manually typed in, not when a date is selected from the popup.




3 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team May 27, 2021 11:03 AM UTC

Hi Andrew, 

Thanks for contacting Syncfusion support. 

We would like to know you that the native change event will not triggered when choose the value from popup. Because when we choose date value from popup, we update the value of input to changed value and so the native change will not triggered.  

You can ensure the same scenario with the native input type date, when dynamically change the date using button click the change event will not be triggered. The same has been implemented in our component and here we demonstrated with an example sample with native DatePicker for your reference. 


So we suggest you to use our change event as like your given thread: 

<form method="post">  
    <ejs-datepicker floatLabelType="Auto" ejs-for="@Model.Calender" id="Calender" value="@Model.Calender"  
        name="calender" placeholder="@Html.DisplayNameFor(m=>m.Calender)" change="OnChange"></ejs-datepicker>  
    <button id="submit">Submit</button>  
</form>  
<script>  
    function OnChange(args) {  
        alert(args.value);  
    }  
</script>  


Regards, 
Ponmani M 


Marked as answer

AN Andrew May 27, 2021 12:27 PM UTC

Hi Ponmani,

I was afraid of this.  As I have built a tag helper to generate the proper ejs control automatically, I can't directly access the <ejs-> tag. Which is why I was looking for a JS option. Looks like I'll have to hack my way around it.

Thanks for the help!


PM Ponmani Murugaiyan Syncfusion Team May 28, 2021 05:03 AM UTC

Hi Andrew, 

Most welcome. please let us know if you need any other assistance. 

Regards, 
Ponmani M 


Loader.
Up arrow icon