-
Notifications
You must be signed in to change notification settings - Fork 21
Initialisation
Karl edited this page Nov 9, 2017
·
16 revisions
This will create a new instance and add any element found in the DOM with the "ui-selectable"
class name and make them selectable.
const selectable = new Selectable();
If you don't add the "ui-selectable"
class name to your items then simply tell the instance what to look for instead with the filter
option:
const selectable = new Selectable({
filter: ".my-classname"
});
// or
const selectable = new Selectable({
filter: document.querySelectorAll(".my-classname")
});
If your document doesn't have any selectable items yet, e.g. they're added asynchronously via an ajax call, then simply create a new instance as normal, then use the add()
method when they're available:
const selectable = new Selectable();
// items added to DOM ...
// then...
selectable.add(items);