you'll want your class to implement a method called toElement which
returns the Element instance which you'd like inserted in the DOM
(this.button in your class example below).
once it implements this method you can refer to an instance wrapped
by the $ function to have access to the instance's Element. in other
words:
var myButton = new Button();
var domElement = $(myButton);
odd: you can really have the javascript
(new Button()).inject(document.body);
executed with the Button class described below, and receive no
javascript error?
On Sep 12, 2008, at 4.27 PM, Luca Pillonel wrote:
I have a class creating elements. I.E.
var Button = new Class({
initialize : function(){
this.button = new Element('div', {html : 'my button'});
return this.button;
},
setContent : function(content){
this.button.set('html', content);
}
});
So i can create an element in my DOM like this :
var myButton = new Button().inject(document.body);
But how can I make
myButton.setContent('some new content');
?
Thank you