Maximum call stack size exceeded error

后端 未结 30 2556
独厮守ぢ
独厮守ぢ 2020-11-21 23:51

I am using a Direct Web Remoting (DWR) JavaScript library file and am getting an error only in Safari (desktop and iPad)

It says

Maximum call

30条回答
  •  名媛妹妹
    2020-11-22 00:21

    I know this thread is old, but i think it's worth mentioning the scenario i found this problem so it can help others.

    Suppose you have nested elements like this:

    
        
        
    
    

    You cannot manipulate the child element events inside the event of its parent because it propagates to itself, making recursive calls until the exception is throwed.

    So this code will fail:

    $('#profile-avatar-picker').on('click', (e) => {
        e.preventDefault();
    
        $('#profilePictureFile').trigger("click");
    });
    

    You have two options to avoid this:

    • Move the child to the outside of the parent.
    • Apply stopPropagation function to the child element.

提交回复
热议问题