diff --git a/source/Ox.UI/Ox.UI.js b/source/Ox.UI/Ox.UI.js index 9355983c..81a06e6a 100644 --- a/source/Ox.UI/Ox.UI.js +++ b/source/Ox.UI/Ox.UI.js @@ -373,7 +373,7 @@ Ox.load.UI = function(options, callback) { }); // ... Ox.UI.getOxElement = function(element) { - return Ox.$elements[Ox.$(element).attr('data-oxid')]; + return Ox.$elements[Ox.$(element).data('oxid')]; }; /*@ Ox.UI.hideLoadingScreen hide loading screen diff --git a/source/Ox.UI/js/Core/JQueryElement.js b/source/Ox.UI/js/Core/JQueryElement.js index d22c4e14..ac7c3477 100644 --- a/source/Ox.UI/js/Core/JQueryElement.js +++ b/source/Ox.UI/js/Core/JQueryElement.js @@ -9,9 +9,7 @@ Ox.JQueryElement = function($element) { //@ id Unique id this.oxid = Ox.uid(); //@ $element The jQuery-wrapped DOM element - this.$element = $element - .attr({'data-oxid': this.oxid}) - .data({oxid: this.oxid}); + this.$element = $element.data({oxid: this.oxid}); //@ 0 The DOM element (for compatibility with jQuery) this[0] = this.$element[0]; //@ length 1 (for compatibility with jQuery) diff --git a/source/Ox/js/DOM.js b/source/Ox/js/DOM.js index 0ed04068..35cb4ca1 100644 --- a/source/Ox/js/DOM.js +++ b/source/Ox/js/DOM.js @@ -29,7 +29,8 @@ Ox.$ Generic HTML element, mimics jQuery @*/ Ox.$ = Ox.element = function(value) { - var element = !Ox.isString(value) ? value // window, document or element + var data = {}, + element = !Ox.isString(value) ? value // window, document or element : value[0] == '<' ? document.createElement(value.slice(1, -1)) : value[0] == '#' ? document.getElementById(value.slice(1)) : value[0] == '.' ? document.getElementsByClassName(value.slice(1))[0] @@ -140,6 +141,20 @@ Ox.$ = Ox.element = function(value) { } return ret; }, + data: function() { + var ret; + if (arguments.length == 0) { + ret = data; + } else if (arguments.length == 1 && Ox.isString(arguments[0])) { + ret = data[arguments[0]] + } else { + Ox.forEach(Ox.makeObject(arguments), funciton(value, key) { + data[key] = value; + }); + ret = this; + } + return ret; + }, /*@ empty Empties the inner HTML () -> This element