Created
February 17, 2017 19:51
-
-
Save JesseRWeigel/04e37cd5eb6f98f37c98870715be5721 to your computer and use it in GitHub Desktop.
Materialize Datepicker Set Year Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
let thisInputID, thisPickerID; | |
$('.datepicker').pickadate({ | |
//Other options can go here | |
onOpen: function() { | |
//Get ID for input and this particular picker | |
thisInputID = `#${$(this.$node.context).attr('id')}`; | |
thisPickerID = `${thisInputID}_root`; | |
}, | |
onClose: function() { | |
//Get date from selected day element and save as a variable | |
let date = ($(`${thisPickerID} .picker__day--highlighted`).attr('aria-label')); | |
//Insert date into input | |
$(thisInputID).val(date); | |
}, | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment