Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Draggable Not Working


Hello,
As Draggable's script bundles are separated from Metronic 8 global bundle I decided including draggable from this link:
https://cdn.jsdelivr.net/npm/@shopify/draggable/lib/draggable.bundle.legacy.js

The reason for this I wanto to create widgets in the sidebar that gonna be dragged and dropped into the container in the main page while leaving copy of the dragged widget in sidebars widget list and also I wanted to restrict draggability inside the widget list inside sidebar.

I called dragging functionality with this:

document.addEventListener('DOMContentLoaded', function () {
// Initialize Sortable for the sidebar (elements-list-wrap)
var sidebarSortable = new Sortable(document.getElementById('sidebar-container'), {
group: {
name: 'draggable-zone',
pull: 'clone', // Enable cloning when dragging from the sidebar
},
draggable: '.draggable',
handle: '.draggable-handle',
sort: false, // Disable sorting in the sidebar
onStart: function (evt) {
// Disable the drag handle in the cloned item
var clone = evt.from.lastChild.cloneNode(true);
clone.style.pointerEvents = 'none';
evt.clone = clone;
},
});

// Initialize Sortable for the main page container (item-list-wrapper)
var pageContainerSortable = new Sortable(document.getElementById('droppable-container'), {
group: 'draggable-zone',
draggable: '.draggable',
handle: '.draggable-handle',
mirror: {
appendTo: 'body',
constrainDimensions: true,
},
});
});


But it did not work and I have no console errors sad Dragging acts like text selection.
Need you little help here. Please!


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi,

Can you please refer to this guide to fix it for your version?

if you need any further help please do let us know.

Regards.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(