Advertisement
celphi

Untitled

Jun 26th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. (function(){
  2.  
  3. const $container = document.querySelector('#site_container');
  4.  
  5. const example = () => {
  6. return new Promise(resolve => {
  7. setTimeout(() => {
  8. const $button = document.createElement('a');
  9. $button.href = '#';
  10. $button.innerText = 'EXAMPLE';
  11. resolve($button);
  12. }, 0);
  13. });
  14. };
  15.  
  16. const handleClickButton = (evt) => {
  17. evt.preventDefault();
  18. console.log('Clicked');
  19. }
  20.  
  21. const initApp = async () => {
  22. const $button = await example();
  23. $button.addEventListener('click', handleClickButton);
  24. $container.append($button);
  25. };
  26.  
  27. initApp();
  28.  
  29. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement