I want to create a Class, say MyDiv
, which inherits from the original DOM DIV element.
Later in my code I would like to use it like that:
$('a-container').adopt(new MyDiv('my own set of params'));
I am missing the exact syntax to do it.
I want to create a Class, say MyDiv
, which inherits from the original DOM DIV element.
Later in my code I would like to use it like that:
$('a-container').adopt(new MyDiv('my own set of params'));
I am missing the exact syntax to do it.
You don't necessarily need to extend a specific Element type. If you provide a toElement
method, you can define what'll be *adopt*ed in such a case:
var MyDiv = new Class({
initialize: function() {
this.realDiv = new Element('div',{id:'foo'});
},
toElement: function() {
return this.realDiv;
}
});