Setting containment on a resizable element
Hi,
I'm really new to jquery and the UI code.
I was having a problem with setting a containment on a resizable
element. I made it work by changing the source code of ui.resizable.js
from this:
if (o.containment) {
var oc = o.containment,
ce = (oc instanceof jQuery) ? oc.get(0) :
(/parent/.test(oc)) ? el.parent().get(0) : null;
if (ce) {
to this
if (o.containment) {
var oc = o.containment,
ce = (oc instanceof jQuery) ? oc.get(0) :
(/parent/.test(oc)) ? el.parent().get(0) : null;
ce = el.parent().get(0);
if (ce) {
It appeared as though the variable ce wasn't being initialised. Once I
changed the code I could have a contained draggable element which was
also a contained resizable element.
Now here's the problem... I don't know why it fixed it, my JS skills
are currently limited, however debugging the problem showed the "ce"
wasn't being set, so I just broke up the previous statement and tried
to set it. It was pretty much trial and error. I'm guessing I've done
something that I shouldn't really do, however I've not had a problem
with it since I changed it.
I've created a sample page that shows the fix.
http://www.drag-and-drop.com/containment.zip
I'd be interested in your opinion. (If you have one :)
Regards
James.