cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rostyk1
New Member

Custom Javasrcipt doesnt want to work on Power Apps portal.

Hello guys,

i have this problem with JS on my portal. When using 

 

 

 

 

 

element.innerHTML = '';

 

 

 

 

 

for creating new elements. After saving the code in code editor on portal the part after "element.innerHTML" just cuts off. Here's the code that works on my local: 

 

 

 

 

for (let i = 0; i < itemsCount; i++) {
          let parentElement = document.body;
          let element = document.createElement("div");
          element.setAttribute("class", "item");

          var name = items[i].name;
          var price = items[i].price;
          var desc = items[i].desc;
          var img = items[i].img;
          var qty = items[i].qty;

          element.innerHTML = '<div class="image"><img src=' + img + ' alt="" /></div><div class="description"><span>' + name + '</span><span>TICKET</span></div><div class="quantity"><button class="plus-btn" type="button" name="button"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16"><path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"/></svg></button><input type="text" name="name" value="' + qty + '"><button class="minus-btn" type="button" name="button"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-dash" viewBox="0 0 16 16"><path d="M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8z"/></svg></button></div><div class="total-price">$' + price + '</div>';

          document.getElementById("parent").append(element);
        }

 

 

 

 

Does anyone know what to do with this or how do I write this code without "" and '' because dataverse doesnt seem to like it.

0 REPLIES 0

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,620)