L
L
LionG2019-07-31 09:27:58
HTML
LionG, 2019-07-31 09:27:58

How to correctly combine the HTML skeleton with the JS class into one interactive object that can be dynamically loaded / deleted?

Now it already works, but I suspect that it can be implemented somehow more competently.
A JS file with a bunch of classes is loaded onto the server (each class is written for a specific HTML skeleton (some kind of widget - graph, calculator, chat ...)).
Then, an HTML skeleton with a unique ID is dynamically added to the document of the page, and through the script I create an instance of the class that I bind to the loaded HTML skeleton. (If the skeleton can be assembled, then it is assembled by the class constructor ... but sometimes the data comes already from the server and it is necessary to work with the finished skeleton).
If you delete the skeleton or load another one instead, the instance of the skeleton class object whose skeleton is missing is deleted.
I don't like how self-destruction of an object instance works now ... or rather, checking for the absence of a skeleton.
Now self-destruction is triggered if an error occurs when accessing the skeleton + a dummy timer that the skeleton receives (in case the JS object is waiting for events from the skeleton element that no longer exists)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question