Closed jasondavis closed 8 years ago
This is a simple addition...
Line 1082:
$picker.data('onSelect', opt.onSelect);
Around line 878 I added:
// Generate the handler of a picker
var $input = $(this);
var handler = new PickerHandler($picker, $input);
// Call a event-hanlder for onSelect
var func = $picker.data('onSelect');
if (func != null) {
console.log("dtpicker- Call the onSelect handler");
func(handler, targetDate);
}
Line 1236
"onSelect": null,
And now I can use this new callback like this to make AJAX saves and update DOM when Date is selected:
$('#btn_generate').click(function(){
window.alert("Generate");
$('#date_jit').appendDtpicker({
"onSelect": function(handler, targetDate){
window.alert(handler.getDate());
console.log(targetDate);
},
});
});
Hi, Jason! Thanks very much for nice code :) I was wondering if you could write an example code into jquery.simple-dtpicker.html ?
of course, thanks i'll do it today!
I added a simple example based on the other callback examples. One thing to note is that in the example I have set "dateOnly": true,
as I don't use the Time feature in my current project and the callback is fired when the date is selected so it might need a little work to trigger onSelect
when a Date and Time is selected, however when only a date is shown it should function as it does now.
When I get some time I can try to modify it to work with Date and Time selections, for now this is just for Date selections so the example has the Time disabled.
@mugifly do you need help merging this pull? I think it's a needed modification, specially regarding inline calendars.
I'm sorry for too late merge.
@royzrj Thanks for your thoughtfulness. It needed merge the conflict with few fixes about dateOnly mode and inline mode.
Great!
I wonder why is it invisible on http://mugifly.github.io/jquery-simple-datetimepicker/jquery.simple-dtpicker.html
@dmatora what is invisible?
onSelect example
@dmatora if you want to always show the calendar you must use "inline: true" option
I'm saying that onSelect example exists on github.com but missing on github.io
i checked github.io, didn't see, implemented it, started creating pull request, and then realized that it's actually already implemented, i'm sure i'm not only person who got confused
Yeah, the online examples page is not up to date. You should check the examples page from the repository, you'll find it there.
Added new onSelect Callback function executed when a new Date value is selected/clicked on.