Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draggable and resizable in JqueryUI for an image is not working?

I used below code for dragging and resizing the image,

<!DOCTYPE html>
<html>
    <head lang="en">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>

        <script type="text/javascript">
    $(document).ready(function() {

        $( "#img_content" ).draggable().resizable();

    });
    </script>
    </head>
    <body class='default'>       


<div class="demo">
<!--<div id="img_content" class="ui-widget-content">
    <p>Drag me around</p>
</div>-->

<img id="img_content" class="ui-widget-content" src="Tulips.jpg" />

</div>


    </body>
</html>

resizable is working corretly. but dragging the image not working. if i applied for div structure

<div id="img_content" class="ui-widget-content">
        <p>Drag me around</p>
    </div>

its working fine.

How do i implement drag and resize for image tag?

like image 373
Ravichandran Jothi Avatar asked May 22 '12 13:05

Ravichandran Jothi


2 Answers

You should wrap the image into a div with style="display:inline-block; and then make the div draggable and the image resizable. Working Example

like image 132
daniatic Avatar answered Oct 02 '22 17:10

daniatic


The solution I've found was resizing/making dragable a with a background image. I guess that the element is not draggable and resizable. Well, it works for me. Bye.

like image 31
Eduardo M. Cooper Avatar answered Oct 02 '22 17:10

Eduardo M. Cooper