javascript - 将 jQuery 从 1.11.1 升级到 3.3.1 后的弹出问题

标签 javascript jquery html jquery-mobile

我使用的是 jQuery 1.11.1 和 jQuery Mobile 1.4.5,一切正常。最近我将 jQuery 升级到 3.3.1。我遇到弹出问题。当我尝试通过调用 popupCaptureOptions() 函数在按钮 onlick 中打开弹出窗口时,出现以下错误。

Uncaught TypeError: e.preventDefault is not a function
    at w.Event.preventDefault (jquery-3.3.1.min.js:2)
    at w.Event.preventDefault (jquery-3.3.1.min.js:2)
    at jquery.mobile-1.4.5.min.js:7
    at i (jquery-3.3.1.min.js:2)
    at dispatch (jquery-3.3.1.min.js:2)
    at y.handle (jquery-3.3.1.min.js:2)
    at Object.trigger (jquery-3.3.1.min.js:2)
    at jquery-3.3.1.min.js:2
    at Function.each (jquery-3.3.1.min.js:2)
    at jQuery.fn.init.each (jquery-3.3.1.min.js:2)

我的 html 页面如下所示。

 <div data-role="page" id="previewscreen">
        <main>
            <div data-role="main" class="ui-content" style="margin:0; padding:0;">
                <div id="ID_IMAGE_DIV" class="ID_IMAGE_DIV">
                </div>
            </div>
        </main>
        <div data-role="popup" data-history="false" data-overlay-theme="a" data-position-to="window" id="imagePopup">
            <a class="popup_refrence" href="#" data-rel="back"></a>
            <img id="popupImage" />
        </div>
        <div data-role="popup" data-dismissible="false" data-position-to="window" class="ui-content" id="ID_EXTRACTIONERRORPOPUP">
            <a href="#" id="cancel" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
            <p class='error'>Extraction Failed.</p>
            <div id="ID_MORETEXT"></div>
            <a id="ID_MORE" href="#">Read more</a>
            <p id="extractionfailed"></p>
        </div>
        <div data-role="popup" id="capture_popupalert" data-dismissible="false" data-position-to="window" class="ui-content" data-overlay-theme="b">
            <h4 style="text-align:center; margin-top:10px">Capture Options</h4>
            <hr style=" margin-top: 0;" />
            <div id="back_capture" style="margin-top:5%">
                <div class="ui-grid-a">
                    <a style="background-color:#00b3b3;color:white;margin-left:30px;margin-right:30px;" id="back_capture_button" class="ui-btn ui-corner-all ui-shadow">Capture Back</a>
                </div>
            </div>
            <div id="skip" style="margin-top:5%">
                <div class="ui-grid-a">
                    <a style="background-color:#00b3b3;color:white;margin-left:30px;margin-right:30px;" id="skip_button" class="ui-btn ui-corner-all ui-shadow">Skip</a>
                </div>
            </div>
        </div>
    </div>

我的javascript代码是

var popupCaptureOptions = function() {
        var imgFrontElement = document.getElementById("ID_IMAGE_DIV");
        var content_width = $.mobile.activePage.find("div[data-role='content']:visible:visible").outerWidth();
        $('#capture_popupalert').css({'width':content_width*0.8});
        $("#capture_popupalert").popup("open");
        $("#back_capture").click(function() {
            capturedSide = CAPTURESIDE.CAPTURE_BACK;
            doCapture();
        });

        $("#skip").click(function() {
            $("#capture_popupalert").hide();
            imgFrontElement.style.backgroundColor = "white";
            Utils.showLoadingIndicator();
            if (currentModule == Module.MOBILEID) {
                MobileIDModule.extractData(frontCapturedImage, backCapturedImage, isOnBoardingFlow, region);
            } else if (currentModule == Module.CHECK) {
                CheckDepositModule.extractData(frontCapturedImage, backCapturedImage, isOnBoardingFlow, region);
            }
            frontCapturedImage = null;
        });
    };

请帮我解决这个问题。

最佳答案

非常简单。

jQuery Mobile 1.4.5 不适用于最新的 jQuery 版本。

这些是 jQM 1.4.5 支持的 jQuery 版本:jQuery 1.8 - 1.11/2.1

可以找到更多关于它们的信息 here .

所以要么升级到 jQM 1.5,要么使用旧版本的 jQuery。

关于javascript - 将 jQuery 从 1.11.1 升级到 3.3.1 后的弹出问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51655376/

相关文章:

html - 展示图片和轮播标题

javascript - jQuery:如何使用滑动机制禁用 regform 上的 Tab 键操作

javascript - 如何从链接中添加/删除类

javascript - javascript方法中的美元符号

javascript - DOM 是否使用 jQuery 立即刷新?

python - 无法在 Web 浏览器中从 python 打开 html 文件 - 改为用记事本打开

html - IE11 伪元素动画效果不正常

javascript - 避免在 Play Framework 2.0 中重新提交表单

javascript - 使用 Laravel 发送 Ajax 请求

jquery - KendoUI Grid 根据结果计数动态服务器过滤/排序