Created
September 28, 2018 10:27
-
-
Save nickciolpan/47bad84d48ad02d9408ff1fabd0359a3 to your computer and use it in GitHub Desktop.
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
// 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