add bindOnce to Ox.$

This commit is contained in:
rolux 2012-04-07 01:45:51 +02:00
parent 67a0f82266
commit 9ad4ec6041

View file

@ -146,6 +146,16 @@ Ox.$ = Ox.element = function(val) {
}); });
return this; 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 <f> Binds a function to the click event click <f> Binds a function to the click event
(callback) -> <o> This element (callback) -> <o> This element
@ -214,6 +224,10 @@ Ox.$ = Ox.element = function(val) {
this[0].onmousedown = callback; this[0].onmousedown = callback;
return this; return this;
}, },
remove: function() {
this[0].parentNode.removeChild(this[0]);
return this;
},
/*@ /*@
removeAttr <f> Removes an attribute removeAttr <f> Removes an attribute
(key) -> <o> This element (key) -> <o> This element
@ -237,7 +251,7 @@ Ox.$ = Ox.element = function(val) {
return this; return this;
}, },
unbind: function(event) { unbind: function(event) {
delete this[0]['on' + event]; this[0]['on' + event] = null;
return this; return this;
} }
} : null; } : null;