Skip to content

Instantly share code, notes, and snippets.

@nickciolpan
Created September 28, 2018 10:27
Show Gist options
  • Save nickciolpan/47bad84d48ad02d9408ff1fabd0359a3 to your computer and use it in GitHub Desktop.
Save nickciolpan/47bad84d48ad02d9408ff1fabd0359a3 to your computer and use it in GitHub Desktop.
// The source of truth should be the element that initializes it.
// Have a default fallback
if ($multiSelect.length > 0) {
$multiSelect.each(function () {
let $this = $(this),
dataset = $this.data(),
options = defaults;
// Since the number of options can vary,
// non vital options that have no specified default
// will be extracted from the dataset and added to options
Object.entries(dataset)
.map(property => options[property[0]] = property[1]);
// We initialize the plugin with its
// specific options for each instance
$this.multiselect(options);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment