Create Virtual List from convertToData


#1

I’m stuck with this, and I think it’s simpler than I imagine.

JS file

$$(’#lista-pedido’).on(‘click’, function () {
var formData = app.form.convertToData(’#insumosform’);
console.log(JSON.stringify(formData));

        var listaVirtual = app.virtualList.create({
            // List Element
            el: '.list.virtual-list.lista-pedido.media-list',
            // Pass array with items
            items: formData,
            // List item Template7 template
            itemTemplate: '<li>' +
                '<a href="#" class="item-link item-content">' +
                '<div class="item-inner">' +
                '<div class="item-title-row">' +
                '<div class="item-title"></div>' +
                '</div>' +
                '<div class="item-subtitle">{{**what goes here**}}</div>' +
                '</div>' +
                '</a>' +
                '</li>',
             // Item height
        height: 102,
        });
    });

JSON string (When i check put the names)

{
  "1": [
    
  ],
  "2": [
    
  ],
  "3": [
    
  ],
  "4": [
    "Ajo en Polvo / Granulado"
  ],
  "5": [
    "Albahaca"
  ],
  "6": [
    "Azafrán molido"
  ],
  "7": [
    
  ],...
}

HTML File (Virtual list inside a Popup)

<div class="popup listapopup">
    Any HTML content goes here
         Lista virtual
         <div class="list virtual-list lista-pedido media-list"></div>
                     <a class="link popup-close">Close</a>
  </div>

And thats all.
I don´t know how to pass the data from the JSON to the list.


#2

У вас должен быть массив, а не объект в items.