我尝试以 eric martins 简单模式提交表单。一切正常,只是表单没有提交我在文本字段中输入的数量。有没有人对此有一个巧妙的解决方案?
我的 Jquery 已更新以获得更好的视图,如下面的帖子中所述
<script type="text/javascript">
function image_id_convert(image_id)
{
image_id = parseInt(image_id, 10).toString(35);
while (image_id.length < 6)
{
image_id = 'z' + image_id;
}
return image_id;
}
$('.opener').click(function (event) {
var url = $(this).attr("href")+'/?format=json';
$('#formVariants').modal({
onOpen: function (dialog) {
dialog.overlay.fadeIn('fast', function () {
dialog.container.slideDown('fast', function () {
dialog.data.fadeIn('fast');
});
});
},
onShow:function(dialog) {
$.getJSON(url, function(data) {
var contentHtml = '';
$.each(data.product, function(index, product){
var image = 'http://cdn.webshopapp.com/i/' + image_id_convert(data.product.image) + '/160x120x2/image.jpg';
contentHtml =
'<img src="' + image + '"/>' +
'<div class="variantsContainer">' +
'<div class="pop_headerContainer">' +
'<div class="pop_title"><h3>' + data.product.fulltitle + '</h3></div>' +
'<div class="pop_code">Artikelcode:' + data.product.code + '</div>' +
'<div class="pop_price">€' + data.product.price.price + '</div>' +
'</div>';
});
$.each(data.product.variants, function(index, variant){
contentHtml = contentHtml +
'<form class="formProduct" id="formProduct">' +
'<div class="variants">' +
'<div class="pop_variantTitle"><label>' + variant.title + '</label></div>' +
'<div class="pop_variantQuantity"><label">{{ 'Quantity' | t }}: <input type="text" name="quantity" id="formProductQuantity" value="50" /></label></div>' +
'<div class="pop_variantAdd"><input type="submit" id="submit" class="button green" value="{{ 'Add to cart' | t }}"/></div>' +
'</form>';
contentHtml = contentHtml +
'</div>';
// action="{{ 'cart/add/' | url }}' + variant.id + '" method="post"
/* quantity = $('#formProductQuantity').val();
$('#formProductQuantity').val(quantity);*/
});
$('.formProductContent').html(contentHtml);
});
}
});
return false
})
</script>