Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Draggable Not Working


Hello,
As Draggable's script bundles are separated from Metronic 8 global bundle I decided including draggable from this link:


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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(