2

I am using the Magento 2.3.2 Version.

I have set the popup modal but it is not working into the iPhone safari browser. They give the following error:

TypeError: undefined is not an object (evaluating 'elem.nodeName'

Please check below my popup modal code

require(
    [
        'jquery',
        'Magento_Ui/js/modal/modal',
        'owlslider'
    ],
    function(
        $,
        modal
    ) {
        var options = {
            type: 'popup',
            responsive: true,
            innerScroll: true,
            buttons: []
        };

        var popup = modal(options, $('#popup-mpdal')); //This line Gives error
        $(".country_switcher").on('click',function(){
            $("#popup-mpdal").modal("openModal");
        });
    });

Please give me the solution how to solve this. Thanks in Advance.

3

Hi Hardik you have solved this problem using below ways

1) By putting your model code inside $( document ).ready()

2) Check the length of your div whether you declared div is available or not.

Try the below code.

require(
    [
        'jquery',
        'Magento_Ui/js/modal/modal',
        'owlslider'
    ],
    function(
        $,
        modal
    ) {
        var options = {
            type: 'popup',
            responsive: true,
            innerScroll: true,
            buttons: []
        };

        $(document).ready(function(){     
        $(".country_switcher").on('click',function(){ 
            if ($('#popup-mpdal').length != 0) {  
            var popup = modal(options, $('#popup-mpdal'));
            $("#popup-mpdal").modal("openModal");
            }                                
        });
      });
| improve this answer | |

Your Answer

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

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