Jquery droppable error

Here is my code.

$("#selected").droppable({
drop: function() {
    total = total + 1;
        alert('total : ' + total);
    }
});

I get the following error:

$ ("# selected"). droppable is not a function.

What should be the solution for this?

+3
source share
5 answers

You probably have one of the following issues regarding tags <script>:

  • Is jQuery UI enabled correctly?
  • Is jQuery enabled before jQuery UI? (this should not be a problem, otherwise you will get another error)
  • Is jQuery enabled again later on the page after jQuery UI? (this will erase any plugins, including jQuery UI, as it overrides the object jQuery)

- , , jQuery UI, jQuery, jQuery.

+4

, :

1) jquery.js jqueryui.js script?
2) ?
3) $(document).ready(...) ( , )

+1

JQuery Angular . Dragdrop .

index.html :

 <script src="bower_components/jquery/dist/jquery.js"></script>
 <script src="bower_components/jquery-ui/jquery-ui.js"></script>
 <script src="bower_components/angular/angular.js"></script>
+1

- : , , . , jquery ui.

, . , http://jqueryui.com/download , droppable .

( )

0

( @Paulo Pedroso, Angular).

AngularJS .

, jqLite, JQuery. JQuery, JQuery. .

myApp.directive('jqDrop', ['$rootScope', function ($rootScope) { 
    return {
        restrict: 'A',
        link: function (scope, elm, attr) {

            // NOTE: elm comes in under jqLite, so need to jQuery it.
            $(elm).droppable({
                drop: function (event, ui, x) {
                    // Do stuff here...
                },
                greedy: false,
                over: function (event, ui) {
                },
            });
        }
    };
}]);

( , ), , -, .

0
source

Source: https://habr.com/ru/post/1777164/


All Articles