How to make the jQuery UI Resizable alsoResize reverse direction.
suppose in the html there is two div tag is there, if i resize in upward means the other thing has to resize downward
<script>
$(function() {
$("#resizable").resizable({alsoResize: ".myiframe"});
});
</script>
<div id = "resizable">
This is the resizable content...
</div>
<div class="myframe">
This must resize in reverse direction...
</div>
i tried it but of no use please guide to solve this
Even if the code posted by Simen works very well, here is my code to resize two div vertically (and it works fine)
This should also work to resize another div in the opposite direction.
By modifying the code jQuery uses to implement the
alsoResize
option, we can make our ownalsoResizeReverse
option. Then we can simply use this as follows:The structure of the original
alsoResize
option has been changed over the various versions of jQuery UI and my original code does not work in the newer versions. I'll give the code for adding this functionality in version 1.8.1 and 1.11.4.Only a few things had to be changed, such as the obvious renaming
alsoResize
toalsoResizeReverse
and subtracting thedelta
instead of adding it (what makes the resize reversed). The originalalsoResize
code starts on line 2200 of version 1.8.1 of jQuery UI and line 7922 of version 1.11.4. You can see the few changes needed here.To add the
alsoResizeReverse
functionality, add this to your javascript (This should be put outside of document.ready()):For newer versions of jQuery UI (example is based on v1.11.4):
For older version (based on v1.8.1 -- my original answer):
Here's a demo: http://jsfiddle.net/WpgzZ/
Adapted the ideas from marg t and Joseph Baker - which I think is a far better approach. This method doesn't require any Jquery library hack or plugin to split a div into two panes. Just add a function to offset width in the resizable 'resize' event:
Here's the complete JS fiddle.
Update to jQuery 2.1.1 and jQuery UI 1.11.2.
[http://jsfiddle.net/WpgzZ/1136/][1]
I had a problem getting the "Simen Echholt"-code to work with jQuery 1.9.1/jquery-ui (1.10.2), but it worked when I exchanged "$(this).data("resizable")" with "$(this).data("ui-resizable")".