Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI Draggable function is not working

I've included the jquery library, afterward the jQuery UI library, and it still doesn't work. I am Using Google Chrome browser.

code Follows:

<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.16.custom.min.js" type="type/javascript"></script>
<script type="text/javascript">
    $(function() {
        $( ".drag" ).draggable();
    });
</script>

<div id="aboutBox" class="boxLook boxBg drag"></div>

I can't find any solutions anywhere. The debugger says that the method draggable doesn't exist. But I've added jQuery AND jQuery UI, and the paths are correct! it just doesn't work.

like image 608
AlexMorley-Finch Avatar asked Aug 23 '11 09:08

AlexMorley-Finch


People also ask

How does jQuery ui draggable work?

Draggable() Method This method allows the elements to be dragged with the help of mouse. Using jQuery UI, we can make the DOM(Document Object Model) elements to drag anywhere within the view port. This can be done by clicking on the draggable object by mouse and dragging it anywhere within the view port.

How do I use draggable JS?

Introduction to JavaScript Drag and Drop API By default, only image and text can be draggable. To drag an image, you simply hold the mouse button down and then move it. To drag the text, you need to highlight some text and drag it in the same way as you would drag an image.

How do you make an object draggable in HTML?

To make an object draggable set draggable=true on that element. Just about anything can be drag-enabled: images, files, links, files, or any markup on your page. Our example creates an interface to rearrange columns that have been laid out with CSS Grid.


2 Answers

You have one of these problems:

  1. Your jQuery or jQuery UI Javascript path files are wrong
  2. Your jQuery UI does not include draggable
  3. Your jQuery or jQuery UI Javascript files are corrupted
  4. Your div is unstyled and empty, therefore there is nothing to drag
  5. Something is colliding with your jQuery or jQuery UI so it doesn't work

Your code is correct, and it should work:

http://jsfiddle.net/u7zWA/

like image 121
Kokos Avatar answered Oct 05 '22 18:10

Kokos


Try this :

<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.16.custom.min.js" type="type/javascript"></script>
<script src="js/ui/jquery.ui.draggable.js" type="type/javascript"></script>
<script type="text/javascript">
    $(function() {
        $( ".drag" ).draggable();
    });
</script>

<div id="aboutBox" class="boxLook boxBg drag"></div>

You have to implements the draggable component to your project, and include it ! http://jqueryui.com/download

like image 43
Maxooo Avatar answered Oct 05 '22 17:10

Maxooo