Closed grzegorzjawo closed 10 years ago
This was a bug - should be fixed now. Thanks for reporting!
Still... the error is gone, but I don't get milliseconds. Can you look at this below...
$('#containter').datepair();
var milliseconds = $('#containter').datepair('getTimeDiff');
$("Value").ready(function()
{
$("#txtTarget").keyup(function(event)
{
$("#Result").val(milliseconds);
});
});
Don't use $("#txtTarget").keyup()
; bind to the rangeSelected
event:
$('#container').on('rangeSelected', function(e){
var milliseconds = $('#containter').datepair('getTimeDiff');
// do something with milliseconds value
});
Thanks. It displays seconds, but when I change few times the range, unfortunately it doesn't display new value of seconds. Is there something You can do about it?
$('#containter').on('rangeSelected', function(e){
var milliseconds = $('#containter').datepair('getTimeDiff');
$('#eventsExampleStatus').text('' + milliseconds + '');
I need to see a fully working code sample to help further. Post a link to your app or put code in a jsfiddle.
You're mixing non-jquery
var SearchEl = document.getElementById('container');
var SearchDatepair = new Datepair(SearchEl);
and jquery
var milliseconds = $('#container').datepair('getTimeDiff');
That's why it's not working. Pick one or the other.
Good point. I changed it and it works. Thanks for help!
I'm using http://jonthornton.github.io/Datepair.js/ and I need a variable time difference in days with hours to use in other functions.
I can not find of example of how tu use this method.
When I use it:
$('#container').datepair(); var milliseconds = $('#container').datepair('getTimeDiff'); $('#container').datepair('remove');
I get an error in Firefox: TypeError: data[option] is not a function jquery.datepair.js:30
Thanks a lot for simple example how to get time diff.