// Retrieve the full dataset
element.get('dataset');
// Set some values on the dataset
element.set('dataset', {
foo: 'bar',
baz: 'baz'
});

If you like creating elements via new Element, you can pass the dataset
directly into an element's constructor, like so:

new Element('div',{
dataset: {
foo: 'bar',
baz: 'baz'
}
});

Datasetoptions

It is now common practice for many plugins accepting an element to read plugin
properties directly from said element. The DatasetOptions mixin extends
the core mootools Options mixin to allow you to do just that as easy as
providing a list of options to read and an element to read them from:

The DatasetOptions source priority when reading options is the following:

Data attribute value

Passed options object value

Default plugin option value

This is useful, for example, if you initialize a certain plugin globally with
a set of defaults, to allow override on a per-element basis. A good example
of such a situation is some Tooltip plugin:

$$('.tooltip').each(function(element){
new Tooltip(element, {
position: 'bottom'
});
});
#HTML
<a href="..." class="tooltip">This tooltip will be at the bottom</a>
<a href="..." class="tooltip" data-tooltip-position="top">And this one will be at the top</a>

If you only want to read the options without actually setting them, you can
use the following method:

options = this.getOptionsFromElement(element, options);

You can later use the default setOptions method to set the options to your
plugin.

Extending plugins with DatasetOptions

If you want to extend an existing plugin, which uses DatasetOptions, and want
to provide additional options, you have to do something like this: