I have the following function that opens a modal
$$('.page[data-page=selecciondireccion] [data-action=change-quantity]').on('click', function(e) {
e.preventDefault();
var el = $(this).closest('.swipeout');
var el_product_quantity = el.find('.product-quantity');
var product_unit_price = el.find('.item-after').data('unit-price');
var el_product_amount = el.find('.product-amount');
myApp.prompt('Cantidad',
function(value) {
if(value > 0) {
el_product_quantity.text(value);
el_product_amount.text(product_unit_price * value);
}
updateAmount();
}
);
myApp.swipeoutClose(el);
});
and I generate a list of products dynamically in this way:
$$("#btn-verCarrito").click(function(e){
myApp.showTab("#historialCarrito", true);
//Agregando la lista de productos
var listProductos = $('.products-list');
$.each(valCarrito, function(i){
$('<li/>').addClass('swipeout')
.append($('<div/>').addClass('swipeout-content item-content')
.append($('<div/>').addClass('item-media')
.append('<img src="https://www.dropbox.com/s/v7vadq9iitpheo4/iphone-7-plus-black.png?raw=1" alt="Apple iPhone 7 Plus (Black)" width="55" height="75" />'))
.append($('<div/>').addClass('item-inner')
.append($('<div/>').addClass('item-title-row')
.append($('<div/>').addClass('item-title').text('Contenido dinamico'))
.append('<div class="item-after" data-unit-price="'+valCarrito[i].cantProducto+'">Q<span class="product-amount">'+0+'</span></div>')
)
.append('<div class="item-subtitle">Color: Black | Storage: 128 GB</div>')
.append($('<div/>').addClass('item-text')
.append($('<div/>').addClass('chip chip-small').append('<div class="chip-label"><span class="product-quantity">'+valCarrito[i].cantProducto+'</span></div>')))
)
)
.append($('<div/>').addClass('swipeout-actions swipeout-actions-right')
.append('<a href="#" class="swipeout-action bg-amber" data-action="change-quantity"><i class="swipeout-action-icon fa fa-pencil"></i><span class="swipeout-action-label">Cambiar Cantidad</span></a>'))
.appendTo(listProductos);
updateAmount();
});
e.preventDefault();
});
The detail is in this part of the code:
.append('<a href="#" class="swipeout-action bg-amber" data-action="change-quantity"><i class="swipeout-action-icon fa fa-pencil"></i><span class="swipeout-action-label">Cambiar Cantidad</span></a>'))
when clicking here you must open the modal that is in the function that previously gave. I should send to call the function with this part: data-action="change-quantity"
but with the dynamic content does not send open the mode, now if everything is added statically from the html if you execute the modal.
Thank you.