I am building a JavaScript application which will have plugin/modules which will all have a set of mandatory functions shared among each module's code base.
For example, all the modules might have a function named loadSidebarJsonData()
There will also be a base/core app which runs the show/app.
The apps UI will have an app selector DIV in which a user can select an available module which will trigger a click event handler in the core app code.
In this click event handler I need to be able to run a set of functions on the JavaScript object belong to the selected module.
If the Bookmarks app is selected then I need to run loadSidebarJsonData()
on the Bookmarks JavaScript object.
If the Notebooks module is selected then it needs to run the loadSidebarJsonData()
function on the Notebooks JavaScript object instead.
So inside my core apps JavaScript click event handler I will have access to the name of the clicked on module.
Using that module name, how could I structure my code to have it then call functions on that JS object with the name which will be stored in a string variable when the click event occurs?
Aucun commentaire:
Enregistrer un commentaire