Advertisement
MrModest

Untitled

Oct 26th, 2020
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function createStandBlock(stand) {
  2.   const standUrl = urlTemplate.replace('{0}', stand.standId);
  3.   const changeCompanyIdPath = changeCompanyIdPathTemplate.replace('{0}', stand.companyId);
  4.  
  5.   function handleClick(event) {
  6.     event.preventDefault();
  7.     console.log(event);
  8.     //location.href = event.target.href;
  9.  
  10.     const axiosConfig = {
  11.       headers: {
  12.           'Content-Type': 'application/json;charset=UTF-8',
  13.           'Access-Control-Allow-Origin': true,
  14.           'Access-Control-Allow-Credentials': true,
  15.       }
  16.     };
  17.  
  18.     axios
  19.       .post(`${standUrl}/${changeCompanyIdPath}`, {}, axiosConfig)
  20.       .then(response => { location.href = event.target.href; })
  21.       .catch(error => console.log(error));
  22.   }
  23.  
  24.   return hyperHTML.wire()`
  25.     <div class='stand-block' style='background-color: #${stand.color}'>
  26.       <a href='${standUrl}' title='${stand.name}' onclick='${handleClick}'>
  27.         ${stand.name}
  28.       </a>
  29.     <div>
  30.   `;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement