Dragula - сообщение об ошибке (dragula не является функцией) - PullRequest
0 голосов
/ 14 марта 2019

Мы используем Dragula (drop and drop) JS Lib в нашем приложении SPA. Мне нужна помощь с удалением библиотеки JS при смене страницы. Как и когда я возвращаюсь в данный момент, я получаю следующее сообщение об ошибке: «Драгула не является функцией»

Я попытался удалить Dragula при смене вида с помощью drake.destroy, как предлагается в документации в нижней части страницы Github. Но пока не удалось. Я смотрел на удаление this.dragula как eventListener, удалитьEventListener. Но я не уверен, как добиться успеха с этой идеей.

Сообщение об ошибке:

Uncaught TypeError: Dragula is not a function
    at startDragula (sitebrowse.js:361)
    at showBrowseView (sitebrowse.js:12)
    at doEvent (router.js:51)
    at router.js:4

направлено на строку 361. sitebrowse.js.

function startDragula() {
    if (shoppingCart === 0) {
        $('#dragula_right').addClass("empty-shopping-cart");


/*Line 361 */ this.dragula = 
dragula([document.querySelector('#dragula_left'), document.querySelector('#dragula_right')], {
            copy: function (el, source) {
                /* console.log("copied: " + el + " to source " + source); */
                return source === document.getElementById('dragula_left');
            },
            moves: function (el, source, handle, sibling) {
                return source === document.getElementById('dragula_left'); // elements are always draggable by default
            },
            accepts: function (el, target) {
                return target !== document.getElementById('dragula_left');
            },
            copySortSource: false
        });
...