javascript - Bootstrap Datepicker on change firing 3 times -


hi have been trying date of bootstrap date picker , have been able seems fires 3 times. note: not jquery date picker bootstrap date picker.

using date picker: https://github.com/eternicode/bootstrap-datepicker, not older eyecon.ro one.

 $(".date-picker").on("change", function(e) {       contents = $(this).val();       id = $(this).attr('id');       console.log("onchange contents: " + contents);       console.log("onchange id: " + id);   }); 

html:

<input id="start_date" type="text" data-date-format="yyyy-mm-dd" class="date-picker form-control" /> 

i have used few other options other change,

$('.date-picker').datepicker().change(function(){}; 

but not close date picker, hoping there easy solution this. thx

it not fix problem, using datepicker send through ajax post, 3 change events causing me problems - 3rd event failed. if documentation says use changedate event, doesn't seem right me fire input tag's change event 3 times. value isn't changing 3 times!

i wrote simple 'debounce' function around problem. doesn't fix issue - due multiple change events being fired methods: setvalue (line 508) _setdate:(line 1048) , setvalue (line 508) (version 1.3.0) of widget.

 var lastjqueryts = 0 ;// global variable.  ....  // in change event handler...     var send = true; if (typeof(event) == 'object'){     if (event.timestamp - lastjqueryts < 300){         send = false;     }     lastjqueryts = event.timestamp; } if (send){     post_values(this); } 

it pretty simple, finds jquery 'event', , makes sure values in window of 300ms ignored. in testing happened in 30 msec or so.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -