The fiddle doesn't work because jQuery UI isn't included (so jQuery UI resizable is not known), but also you made a syntax error, you should do this:
$(resize).resizable({
handles: 'w'
});
not this:
$(resize).resizable({,,
handles: 'w',
});
As David remarks in the comments, you should make the panel itself resizable, not an in between splitter element. In the resize handler you can resize the other panel so its width is complementary to the width of the panel you are actually resizing.
UPDATE: This should put you on the right track:
$(resize).resizable({
// only use the eastern handle
handles: 'e',
// restrict the width range
minWidth: 120,
maxWidth: 450,
// resize handler updates the content panel width
resize: function(event, ui){
var currentWidth = ui.size.width;
// this accounts for padding in the panels +
// borders, you could calculate this using jQuery
var padding = 12;
// this accounts for some lag in the ui.size value, if you take this away
// you'll get some instable behaviour
$(this).width(currentWidth);
// set the content panel width
$("#content").width(containerWidth - currentWidth - padding);
}
});
Update 2: I added a minWidth and maxWidth option to my example so you can only resize the left column within these boundaries.
UPDATED fiddle here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…