Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

implement dynamic import on event handler

const handler = () => {
  import ('./create-todo.js').then((module) => { 
   // access any exported function in the module.
   // following createTodo() generates DOM string for Create Todo 
   // set the DOM string on an element. 
   document.getElementById("createTodo").innerHTML = module.createTodo();
});
}
// click event handler added on the hyperlink, “Create Todos”.
document
.getElementById("btnCreateTodo")
.addEventListener("click", handler);
Source by javascript.plainenglish.io #
 
PREVIOUS NEXT
Tagged: #implement #dynamic #import #event #handler
ADD COMMENT
Topic
Name
2+2 =