bug or featureBug: The example for Sortable does not work.
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/draggable.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/sortable.js"></script>
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
<script>
const sortable = new Sortable(document.querySelectorAll('ul'), {
draggable: 'li'
});
sortable.on('sortable:start', () => console.log('sortable:start'));
sortable.on('sortable:sort', () => console.log('sortable:sort'));
sortable.on('sortable:sorted', () => console.log('sortable:sorted'));
sortable.on('sortable:stop', () => console.log('sortable:stop'));
</script>
Inspecting the Google Chrome console:
Uncaught TypeError: Sortable is not a constructor at index.html:11
Thanks
@asmith26,
Change:
const sortable = new Sortable(document.querySelectorAll('ul'), {
draggable: 'li'
});
to
const sortable = new Sortable.default(document.querySelectorAll('ul'), {
draggable: 'li'
});
and it should start working
Thank you for your help!
Most helpful comment
@asmith26,
Change:
to
and it should start working