Closed mirahost closed 7 years ago
Why can't you just call addEventListener
and need jQuery here?
If you desperately want jQuery the same can be done with jQuery, but what is the point of doing so?:
$(element).on('pickmeup-change', function (e) {
console.log(e.detail.formatted_date); // New date according to current format
console.log(e.detail.date); // New date as Date object
})
Why can't you just call addEventListener and need jQuery here?
I am not sure how to do that.
I am not sure how to do that.
You've quoted the exact piece that does it last time:) Anyway, you can use jQuery version I've posted earlier.
I understand what you are saying. What I originally quoted wasn't working. Which spurred me to ask for help. This gets a response, but returns "TypeError: e.detail is undefined"
$("#pickup_date").on('pickmeup-change', function (e) { console.log(e.detail.formatted_date); // New date according to current format console.log(e.detail.date); // New date as Date object });
This is better, so event is fired and captured by jQuery, just e.detail
property isn't there while it should.
Add debugger
statement at the beginning of the callback and open Dev Tools in your browser. Then you can inspect e
variable and see what it inside.
Just so you can get a full view of what I am trying to do:
This previously worked:
var d = new Date();
pickmeup('#pickup_date',{
format : 'm/d/Y',
hide_on_select: true,
calendars : 2,
min : d,
change : function (formatted_date) {
$('#return_date').val(addDays(formatted_date,2));
}
});
Now that the above no longer works, I am exploring new options. This doesnt work yet:
$("#pickup_date").on('pickmeup-change', function (e) {
$('#return_date').val(addDays(e.formatted_date,2));
});
Here is another demo that works: https://jsfiddle.net/qx152r6r/176/ Maybe you have very old jQuery or something else.
Add debugger statement at the beginning of the callback and open Dev Tools in your browser. Than you can inspect e variable and see what it inside.
Thank you. You got me on the right track so I can sort this out.
What is the current version for jquery? I am updating an older site which is using the jquery dependent version. I've included the latest version into the site without jquery dependency, but we are still using jquery and it isnt working correctly.
My specific issue is with the change callback. This was previously called through the initialization, but this method doesnt work anymore:
The docs recommend this method, but it doesnt work with jquery:
What is the correct jquery method for the change callback?