-
Notifications
You must be signed in to change notification settings - Fork 204
Add a JavaScriptHooks module to the core for modules to depend on #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| onSelect: ___selected, | ||
| onClose: ___closed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BernhardBaumrock am I doing this correctly here? Or what would the correct callback be for it to be hookable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it again, I think, I need to do something like this:
// assume $thisobject is the InputfieldDatetimeDatepicker object
onSelect: function(datetime, $datepicker) {
$thisobject.selected(datetime, $datepicker);
}
onClose: function(datetime, $datepicker) {
$thisobject.closed(datetime, $datepicker);
}| // init datepickers present when document is ready | ||
| $("input.InputfieldDatetimeDatepicker:not(.InputfieldDatetimeDatepicker3):not(.initDatepicker)").each(function(n) { | ||
| InputfieldDatetimeDatepicker($(this)); | ||
| ProcessWire.wire(InputfieldDatetimeDatepicker($(this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InputfieldDatetimeDatepicker might need to be a class or return itself at the end...
| // init datepicker that should appear on focus (3) of text input, that wasn't present at document.ready | ||
| $(document).on('focus', 'input.InputfieldDatetimeDatepicker3:not(.hasDatepicker)', function() { | ||
| InputfieldDatetimeDatepicker($(this)); | ||
| ProcessWire.wire(InputfieldDatetimeDatepicker($(this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InputfieldDatetimeDatepicker might need to be a class or return itself at the end...
This is a draft PR which adds JavaScript hooks to the core. Based on #322.
For more details about what this is trying to achieve, see https://processwire.com/talk/topic/30365-lets-bring-hooks-to-javascript/
This includes a small example for InputfieldDateTime which exposes two example hooks for when a date is selected and when the datepicker is closed.