I’ve run into a javascript question that I don’t know how to resolve. I’m grouping a bunch of variables and methods into a DocManager object. Everything related to managing “documents” in my application lives here. Basically, the DocManager acts like a class with a single instance.
Ex:
var DocManager = {
doc_list : [], //Array of documents containing content and metadata
doc_index : 0, //Index of the currently visible document
loadDocList : function( collection_id, csrf_token, seq_list ){
...
},
showDocument : function(seq_index){
...,
},
...
};
Now I’ve run into a situation where I’d like to subclass DocManager for use on different pages with different controls. I need to add some methods and overwrite others. Most of the functionality the object will stay the same.
What’s the easiest way to do this? I know javascript has a class/prototyping syntax for full-fledged object-orientation, and others have built OOP frameworks for js, but that seems like overkill for this situation. I’d prefer to not learn a lot of new syntax to carry out this simple kind of object orientation. What would you recommend?
You can simply overwrite the functions you have assigned to it.
from that moment it’ll use the new function assigned.