Moazzam Khan
Moazzam Khan

Reputation: 3170

jQuery resizable issue if applied to child element of a resizable

Here is my complete code, which is derived from jQuery Resizable Example -

In my example I have two div elements, with id parent and child, where child element is inside parent element. My Problem is I am not able to resize parent element, even I have made it resizable. Has anyone faced the similar issue?

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Resizable - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

  <style>
  #parent {
    padding: 40px;
    width:400px;
    height:400px;
  }

  #child { 
    width: 150px;
    height: 150px;
  }

  </style>
  <script>
  $(function() {    
    $( "#child" ).resizable();
    $( "#parent" ).resizable();
  });
  </script>
</head>
<body>

<div id="parent" class="ui-widget-content">
  <h3>Parent</h3>
    <div id="child" class="ui-widget-content">
        <h3>Child</h3>
    </div>
  </div>
</body>
</html>

NOTE

Playing with the code, I just found out, this problem only occur is I make child element reseizable before parent element. As in code -

  $(function() {    
    $( "#child" ).resizable();
    $( "#parent" ).resizable();
  });

If I change the order to -

  $(function() {    
    $( "#parent" ).resizable();
    $( "#child" ).resizable();
  });

it will work smoothly. I am not sure why it is happening.

I will try looking into jQuery resizable code but if someone already have faced and solve this issue it will be very helpful.

-Thanks

Upvotes: 4

Views: 250

Answers (1)

Robin Leboeuf
Robin Leboeuf

Reputation: 2116

A ticket has been opened about this on jQuery bugtracker (ticket #7711), but as you can see, it was considered has "not a bug", specifying the work-around you found by yourself as a solution:

As a work-around, initialize the outer/parent resizable first and both are resizable

Upvotes: 1

Related Questions