May 2017
Intermediate to advanced
448 pages
10h 10m
English
Now it's time to make our widget customizable. As we saw when constructing the .shadow() plugin, it's friendly to provide a customizable set of defaults for a widget, and then to override those defaults with options the user specifies. Nearly all of the work in this process is performed by the widget factory. All we need to do is to provide an options property:
options: { offsetX: 10, offsetY: 10, content: element => $(element).data('tooltip-text') },
The options property is a plain object. All the valid options for our widget should be represented, so that none of them are mandatory for the user to provide. Here we're supplying x and y coordinates for the tooltip relative to its trigger element, ...
Read now
Unlock full access