5

I have created popup on href click and on click popup is opening fine. But I want to remove Continue button from modal-footer which is just used to close the popup. Want to remove it. Any idea?

modal-form.js is as below.

define([
    'jquery',
    'Magento_Ui/js/modal/modal'
],
function($) {
    "use strict";
    //creating jquery widget
    $.widget('Vendor.modalForm', {
        options: {
            modalForm: '#personilized-modal-form',
            modalButton: '.open-modal-form'
        },
        _create: function() {
            this.options.modalOption = this._getModalOptions();
            this._bind();
        },
        _getModalOptions: function() {
            /**
             * Modal options
             */
            var options = {
                type: 'popup',
                responsive: true,
                title: 'Personilized Custom Jewelery',
                buttons: [{
                    text: $.mage.__('Continue'),
                    class: '',
                    click: function () {
                        this.closeModal();
                    }
                }]
            };

            return options;
        },
        _bind: function(){
            var modalOption = this.options.modalOption;
            var modalForm = this.options.modalForm;

            $(document).on('click', this.options.modalButton,  function(){
                //Initialize modal
                $(modalForm).modal(modalOption);
                //open modal
                $(modalForm).trigger('openModal');
            });
        }
    });

    return $.Vendor.modalForm;
});

3 Answers 3

15

Why not just remove buttons from footer?

_getModalOptions: function() {
    /**
     * Modal options
     */
    var options = {
        type: 'popup',
        responsive: true,
        title: 'Customer Details',
        buttons: []
    };

    return options;
},
2
  • In my opinion, this is the best/tidiest option.
    – Dan Norris
    Commented Mar 28, 2019 at 11:07
  • best answer. working fine Commented Aug 8 at 12:01
8

Got the solution to add opened function getModalOptions. Something like this,

        _getModalOptions: function() {
            /**
             * Modal options
             */
            var options = {
                type: 'popup',
                responsive: true,
                title: 'Customer Details',
                buttons: [{
                    text: $.mage.__('Continue'),
                    class: '',
                    click: function () {
                        this.closeModal();
                    }
                }],
                opened: function($Event) {
                    $(".modal-footer").hide();
                }
            };

            return options;
        },
0

Here is the simple but full code which I made for my task, thought this full-code might be helpfull for others

require(
[
    'jquery',
    'Magento_Ui/js/modal/modal'
],
function(
    $,
    modal
) {

    var options = {
        type: 'popup',
        responsive: true,
        innerScroll: true,
        buttons: []
    };

    $('#approvalsModal').modal(options,{
        closed: function(){
           // Do some action when modal closed
        }
    });

    $(".approvalsModal").click(function(){
        $("#approvalsModal").modal('openModal');    
    });

    }
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.