gumi
gumi copied to clipboard
Merge $elem.data() with options
Change line 44 from
this.options = $.extend({}, defaults, options);
to
this.options = $.extend({}, defaults, this.$elem.data(), options);
what problem is this solving?
In the scenario where I want to initialize all gumi dropdowns once in the JS, but provide different options to each via data- attributes.
currently, you can override options on an element by doing:
var gumiInstance = $('.gumi-instance').data('gumi');
gumiInstance.options = $.extend(gumiInstance.options, {
// my new options
});
gumiInstance.update();
I do however, like the idea about adding options to each instance based on the data-attributes on the root node. It provides an easy interface that follows the same pattern as the rest of the plugin and will allow "initial" gumi instance customization without having to do much programatically.
I'm leaving this issue open for now, to tackle that design and update the documentation once it's done.