gumi icon indicating copy to clipboard operation
gumi copied to clipboard

Merge $elem.data() with options

Open mattjs opened this issue 10 years ago • 3 comments

Change line 44 from

this.options = $.extend({}, defaults, options);

to

this.options = $.extend({}, defaults, this.$elem.data(), options);

mattjs avatar Jul 22 '14 21:07 mattjs

what problem is this solving?

b1lly avatar Jul 22 '14 21:07 b1lly

In the scenario where I want to initialize all gumi dropdowns once in the JS, but provide different options to each via data- attributes.

mattjs avatar Jul 22 '14 21:07 mattjs

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.

b1lly avatar Jul 23 '14 14:07 b1lly