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 Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,775)