From 9ad4ec6041dab0a92f513f1afb228f941432b47d Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 7 Apr 2012 01:45:51 +0200 Subject: [PATCH] add bindOnce to Ox.$ --- source/Ox/js/DOM.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/Ox/js/DOM.js b/source/Ox/js/DOM.js index 7acb6c18..f60befa5 100644 --- a/source/Ox/js/DOM.js +++ b/source/Ox/js/DOM.js @@ -146,6 +146,16 @@ Ox.$ = Ox.element = function(val) { }); return this; }, + bindOnce: function(events) { + var that = this; + Ox.forEach(Ox.makeObject(arguments), function(callback, event) { + that[0]['on' + event] = function() { + that.unbind(event); + callback(); + }; + }); + return this; + }, /*@ click Binds a function to the click event (callback) -> This element @@ -214,6 +224,10 @@ Ox.$ = Ox.element = function(val) { this[0].onmousedown = callback; return this; }, + remove: function() { + this[0].parentNode.removeChild(this[0]); + return this; + }, /*@ removeAttr Removes an attribute (key) -> This element @@ -237,7 +251,7 @@ Ox.$ = Ox.element = function(val) { return this; }, unbind: function(event) { - delete this[0]['on' + event]; + this[0]['on' + event] = null; return this; } } : null;