3

Magento2 - popup open in ajax response. So all values come from the controller and set in the popup, but attributes options are not shown.

\vendor\magento\module-checkout\view\frontend\templates\cart\item\renderer\actions\edit.phtml

<?php if ($block->isProductVisibleInSiteVisibility()):  ?>

<a class="action action-edit display-before" data-id="<?php echo $itemId; ?>" data-product-id="<?php echo $productId; ?>"
   href="<?= /* @escapeNotVerified */ $block->getConfigureUrl() ?>"
   title="<?= $block->escapeHtml(__('Edit item parameters')) ?>">
    <span>
        <?= /* @escapeNotVerified */ __('Edit') ?>
    </span></a><?php endif ?>

my ajax popup

<script type="text/javascript">
//jquery for show popup in ajax responce
require(['jquery'],function($){
    jQuery(document).ready(function(){
        jQuery('.display-before').on('click',
        function(e){
            e.preventDefault();
            var itemId = $(this).attr("data-id");
            var productId = $(this).attr("data-product-id");
            //alert(itemId);
            jQuery.ajax({
                url:"<?php echo $this->getUrl('checkout/cart/configure');?>",
                method:'GET',
                dataType:"json",
                data: {
                    id : itemId,
                    product_id : productId,
                },
                showLoader: true,
                success: function(response) {
                    var name = response['product_name'];
                    var qty = response['qty'];
                    var item_id = response['item_id'];

                    require(
                        [
                            'jquery',
                            'Magento_Ui/js/modal/modal'
                        ],
                        function (
                            $,
                            modal
                        ) {
                            var modaloption = {
                               type: 'popup',
                               modalClass: 'modal-popup',
                               responsive: true,
                               innerScroll: true,
                               clickableOverlay: true,
                               title: ''
                            };
                            var callforoption = modal(modaloption, $('.modal'));
                            if($('.modal').modal('openModal')){
                                $('.modal').show();
                                $('#name').html(name);
                                $('#qty').attr('value',qty);
                                $(".item_id").attr("value",item_id);
                            }
                        }
                    );
                }
            });
        });
    });
});</script>
  • please attach your code – Rk Rathod Jun 12 at 11:43
  • yeah, now, please check. – Monark Bhawani Jun 12 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.