I'm working on adding checkbox functionality that controls adding new checkboxes to a div
element as well a tracking checkbox behavior. My goal is to make this dirt simple. I've noticed that there is some JavaScript function prototypes for creating objects such as checkboxes and also controlling basic behavior such as visibility, whether its checked or disabled and maybe even adding a label or image next to the checkbox. My plan is to add this to an array or list and how can this be done?
I just need basic class object in JavaScript to be created to track just whether its checked, visible, or disabled. In my case when its disabled it will not be checked, but may change in a later release. I've looked at GWT and ZWT JavaScripting libraries and they seem too complicated. Is there a simple solution I can do myself?
Looking for some constructive criticism, a good link or two for reference, and perhaps an estimate on whether this is feasible and how would I add a checkbox to the class below, and do I also have to worry about adding events to this? And what would be the best way to track multiple famous people in this example: a list, an array, or another class? I'm thinking a dynamic array of some kind.
// Constructor for dynamic checkbox classes
var FamousPerson = function (id, checkStatus, visibleStatus, enabledStatus) {
this.id = id; // primary key for a person for a specific row
this.checkStatus = checkStatus;
this.visibleStatus = visibleStatus;
this.enabledStatus = enabledStatus;
}
FamousPerson.prototype.getId() = function () {
return this.id; // id is reference stored in xml or database row
};
FamousPerson.prototype.update = function (checkStatus, visibleStatus, enabledStatus) {
// note: don't update id
this.checkStatus = checkStatus; // boolean 0 is not checked, 1 is checked
this.visibleStatus = visibleStatus; // boolean 0 is not visible, 1 is visible
this.enabledStatus = enabledStatus; // boolean 0 is not enalbed, 1 is enabled
};
FamousPerson.prototype.getCheckStatus = function () {
return this.checkStatus;
};
FamousPerson.prototype.getVisibleStatus = function () {
return this.visibleStatus;
};