SortableJS / jquery-sortablejs

A jQuery binding for SortableJS
https://sortablejs.github.io/Sortable/
200 stars 54 forks source link

Sortable is not a constructor #3

Open treyan94 opened 4 years ago

treyan94 commented 4 years ago

I keep getting Sortable is not a constructor when using it with Webpack in Laravel.

import Sortable from 'sortablejs';
import 'jquery-sortablejs';

window.Sortable = Sortable;
window.$ = window.jQuery = require('jquery');

It works fine when I use CDN. What could be causing this?

owen-m1 commented 4 years ago

@treyan94 Are you importing it in a NodeJS context? And why do you have window.Sortable = Sortable? Sortable adds itself to the window when you import it.

dammainikilraj commented 4 years ago

sortable error facing the same error from long back. could any one help me out on this.

Added screen shot for your reference.

Thanks in advance!

Padam87 commented 4 years ago

This issue happens with the newer versions of sortablejs.

Downgraded to 1.9, all fine.

mariovalney commented 4 years ago

Downgrade is (often) not the best solution.

To 1.10+ try:

/**
 * SortableJS
 */
window.Sortable = require('sortablejs').Sortable;
dartanian300 commented 3 years ago

I'm having the same issue but @mariovalney's answer isn't working. Still getting the Sortable is not a constructor error. Any thoughts?

window.Sortable = require('sortablejs').Sortable;
import 'jquery-sortablejs';

jquery sortable: v1.0.1 sortablejs: v1.14.0

barbuslex commented 2 years ago

I have the same issue... Anyone have the solution ?

daocatt commented 2 years ago

I have the same issue... Anyone have the solution ?

try Sortable.Sortable.

console.log(Sortable) you will see three module.

raysuelzer commented 1 week ago

Is there any way to use a CDN version of sortableJS. I have a simple app and dont' really want to go through setting up an entire build process...