0

製品をバスケットに追加しようとしていますが、ユーザーが特定の選択入力からオプションを選択しない場合、ユーザーが [バスケットに追加] をクリックしたときに表示されるブートストラップ モーダル ウィンドウにその選択を表示したいと考えています。任意のオプションを選択します。その後、ユーザーはオプションを選択した場合にのみ続行します。これまでのコード:

$('#button-cart').bind('click', function() {
    $.ajax({
        url: 'index.php?route=checkout/cart/add',
        type: 'post',
        data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
        dataType: 'json',
        success: function(json) {
            $('.success, .warning, .attention, information, .error').remove();

            if (json['error']) {
                if (json['error']['option']) {
                    for (i in json['error']['option']) {

                         $('#deleteMessage').modal();
                         $('.modal-body').after('<span class="error">' + json['error']['option'][i] + '</span>');

                    }
                }
            } 

            if (json['success']) {
                $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');

                $('.success').fadeIn('slow');

                $('#cart-total').html(json['totalProducts']);

                $('html, body').animate({ scrollTop: 0 }, 'slow'); 
            }   
        }
    });
});

それを行う方法についてのアイデアは大歓迎です! ありがとうございました!

4

1 に答える 1

2

you can do this by checking before you open the modal dialog for the the selected values, if the user did not selected a set of values then you can just show those dropdowns inside the modal dialog so the user can selected them. After the user will click on the save button you are going to validate it on the client or on the server, or on both, your choice. If the user did not select any values even though he has the modal dialog opened, you can just show him an alert() with a message that he should select a value and only after that he can proceed.

If you really wont be able to solve it, i`ll provide the code for it.

UPDATE

I come with an update to this, here is the code, if you need something different please tell

http://jsfiddle.net/xrQzR/

于 2013-11-12T22:17:33.393 に答える