Skip to content

Instantly share code, notes, and snippets.

@softtama
Created August 20, 2016 06:13
Show Gist options
  • Select an option

  • Save softtama/e9e0746e70c1d6a6d24ef6360ea11bdf to your computer and use it in GitHub Desktop.

Select an option

Save softtama/e9e0746e70c1d6a6d24ef6360ea11bdf to your computer and use it in GitHub Desktop.
Pikaday: Enable specific dates, disable the others
/**
* Enable specific dates, disable the others
* -----------------------------------------
* Using disableDayFn native function from Pikaday,
* you can use array of dates (or in my code, array of date strings)
* to make them the only dates that can be selected.
*
* Plugin: Pikaday (https://github.com/dbushell/Pikaday/)
*
* require jQuery
* require moment.js
*
*/
disableDayFn: function (date) {
var enabled_dates = ["2016-08-20", "2016-08-22", "2016-08-30"]; // dates I only want to enabled.
if ($.inArray(moment(date).format("YYYY-MM-DD"), enabled_dates) === -1) {
return date;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment