B
Bill M.
Hello,
I would like to extend or sub-class the base HTMLSelectElement and add some
custom properties and methods. So far this works to create a new select
element.
var new_select= new Selector('new_select');
Selector = function(id) {
var container = document.getElementById(id);
selector = document.createElement("select");
container.appendChild(selector);
selector.id = id;
selector.name = id;
return selector;
}
but the prototype mentods are not showing up ...
Selector.prototype.setOptions = function(optionlist) {
...
}
.... so this doesn't work: new_select.setOptions(optionlist);
what would be the proper way do to this? Do I need to sub-class from a DOM
object that exposes a constructor to create elements (e.g.
Selector.prototype = some_constructor)?
Thanks,
Bill
I would like to extend or sub-class the base HTMLSelectElement and add some
custom properties and methods. So far this works to create a new select
element.
var new_select= new Selector('new_select');
Selector = function(id) {
var container = document.getElementById(id);
selector = document.createElement("select");
container.appendChild(selector);
selector.id = id;
selector.name = id;
return selector;
}
but the prototype mentods are not showing up ...
Selector.prototype.setOptions = function(optionlist) {
...
}
.... so this doesn't work: new_select.setOptions(optionlist);
what would be the proper way do to this? Do I need to sub-class from a DOM
object that exposes a constructor to create elements (e.g.
Selector.prototype = some_constructor)?
Thanks,
Bill