What do you mean by the palette 'object'?
There are the 'Class instance' and the 'Element'.
The class instance is the part that generates the element and controls
it.
You generate it like this:
var palette = new Q.Palette("id_of_the_input", { colors:
['#31332E','#585C53','#868C7F','#E0E3DC'] });
The class instance is now saved in the variable 'palette'.
And by creating an instance of Q.Palette the Element is generated by
the class.
Now if you delete the input from the dom you will break the link
between the class instance and the input forever.
This means that if you want to re-create an input you will need to
create a new class instance which will on it's turn create a new
Element.
You can probably see it coming.
If you do this a few times you will have multiple unused class
instances and element lying around.
So I suggest that if you want to dynamically generate and delete an
input with a palette attached you create a controller class.
Something like this:
// your controller class
var PaletteGenerator = Class.create({
initialize: function(inputId, tdinput) {
// generate input
this.qPalleteInput = new Element("input", { id: inputId, readonly:
'readonly' });
this.qPalleteInput.setStyle({ width: '150px' });
tdinput.insert(this.qPalleteInput);
// create palette instance
this.palette = new Q.Palette(inputId);
},
destroy: function() {
this.qPalleteInput.remove();
this.palette.holder.remove();
this.palette = null;
}
});
// create instance 1
var instance1 = new PaletteGenerator('qPal_L1', tdinput);
// create instance 2
var instance2 = new PaletteGenerator('qPal_L2', tdinput);
// create instance 3
var instance3 = new PaletteGenerator('qPal_L3', tdinput);
// delete instance 2 for example
instance2.destroy();
// delete instance 3
instance3.destroy();
Hope this helps.
Wout
On Dec 7, 11:25 pm, Kostas Tsimirikas <
kostas...@gmail.com> wrote:
> Ok, but how can I get the "palette" object?Can I simply call
> document.getElementById()?Also, what is the "holder" object?
> Could you please provide me with a quick example?
>
> 2010/12/7 wonderingwout <
boysabr...@googlemail.com>