1
0
Fork 0
forked from 0x2620/oxjs

Only return Ox.Element if exactly one jquery element is return.

Fixes use of find, children
This commit is contained in:
j 2011-12-29 15:40:08 +05:30
commit ac4dd51ed7
6 changed files with 14 additions and 16 deletions

View file

@ -10,8 +10,7 @@ Ox.JQueryElement <function> Wrapper for jQuery
$element <object> jQuery DOM Element
@*/
// fixme: it seems that children(), find() etc. don't work directly,
// and still have to be called on the $element
// fixme: now that children(), find() work, change code to call find directly.
Ox.JQueryElement = function($element) {
var that = this;
@ -48,10 +47,12 @@ Ox.forEach($('<div>'), function(val, key) {
}
});
ret = that.$element[key].apply(that.$element, args);
// if the $element of an ox object was returned
// if exactly one $element of an ox object was returned
// then return the ox object instead
// so that we can do oxObj.jqFn().oxFn()
return ret && ret.jquery && Ox.UI.elements[id = ret.data('oxid')]
return ret && ret.jquery
&& ret.length == 1
&& Ox.UI.elements[id = ret.data('oxid')]
? Ox.UI.elements[id] : ret;
};
}