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:
parent
771d2be37b
commit
ac4dd51ed7
6 changed files with 14 additions and 16 deletions
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue