Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery droppable error

Here is my code.

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

I am getting following error:

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

What should be the solution for this?

like image 520
gautamlakum Avatar asked Nov 27 '10 09:11

gautamlakum


3 Answers

You likely have one of the following issues with respect to your <script> tags:

  • Is jQuery UI being included properly at all?
  • Is jQuery included before jQuery UI? (this shouldn't be the issue, or you'd get a different error)
  • Is jQuery being included again later in the page, after jQuery UI? (this will erase any plugins, including jQuery UI, since it re-defines the jQuery object)

The third is a very common overlooked issue, where all of the plugins that jQuery UI add get blown away by another jQuery include overwriting the jQuery object.

like image 113
Nick Craver Avatar answered Nov 09 '22 18:11

Nick Craver


Just a couple of standard things to check:

1) Have you included jquery.js & jqueryui.js before this script?
2) is there a syntax error before this line?
3) Are you doing this inside a $(document).ready(...) or equivalent (shouldn't necessarily be a problem, but just in case)

like image 42
TJB Avatar answered Nov 09 '22 20:11

TJB


Adding JQuery scripts before Angular worked for me. Dragdrop documentation lacks this piece of information.

My index.html ended up like this:

 <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>
like image 27
Paulo Pedroso Avatar answered Nov 09 '22 18:11

Paulo Pedroso