I am trying to use the jQuery resizable to resize my div, I've got it to work pretty good except that after the stop
event, jQuery UI would revert my %
value back to pixel
value.
I've a working fiddle here: http://jsfiddle.net/totszwai/j60h38fy/5/
When you drag the current
container for the first time, it would calculate all the value correctly, but after the stop
event, jQuery UI would update the % and change it back to pixel... so next time you drag it again, the % is lost.
How do you force jQuery to set the width value to %? I could technically use something like setTimeout, but that would be way too ugly.
And I do not want a solution to manipulate the divs in pixel, because I could technically add n-divs in my setup and that code with % should work with n-divs.
If you take a look at my neighbor
div, the % is kept there, only the current
got overwritten. I've also tried to play around with ui.element
directly as well as setting the ui.size.width
to my % but none of that work either.
Update: A workaround is to store the data everytime at the stop
event and never check it again at the start
, however, this still doesn't solve the issue where stop
returns incorrect pixel value. See updated jsFiddle: http://jsfiddle.net/totszwai/j60h38fy/6/
If only jQuery resizable take my % value, everything would've worked as expected.
Solved: Well, I've accepted apaul34208
's answer, since i did asked for how to use %. However, to actually solve what I originally wanted to solve, I end up using pixels instead. See the answer that I posted below, if that answer helped you, please upvote that instead.