Currently, I am delving into the concept of object inheritance in JavaScript through a practical exercise where I am creating an online editor similar to the one I am currently using.
However, I find myself slightly confused as I aim to utilize data-* attributes to manipulate my editor:
<div class="editor__wrapper">
<div data-editor="toolbar">
</div>
<textarea data-editor="textarea"></textarea>
</div>
My initial approach was like this:
$(window).on('load', function() {
$('[data-editor]').each(function() {
var element = $(this);
var editor = new Editor(element);
});
});
and defined the editor as follows:
var Editor = function(element) {
this.element = element;
};
However, this is not exactly what I had in mind.
I desire to initialize with data-* attributes, creating a toolbar for toolbar elements and an editor for textarea elements, while having them inherit common properties from a parent element.
I'm feeling a bit lost at the moment. Any thoughts or suggestions on a better approach would be greatly appreciated!
Thank you.