jQuery Mobile精美的弹出框在jQuery 2.1.3中可用,但在jQuery 2.2.4中出现问题。

huangapple go评论37阅读模式
英文:

jQuery-Mobile fancy popup box works with jQuery 2.1.3 but breaks with jQuery 2.2.4

问题

以下是您要的翻译部分,代码部分不做翻译:

Years ago, I found this "fancy alert" popup box for use with jQuery mobile. I've been using it in my Cordova apps for years.

前些年,我找到了这个适用于 jQuery 移动端的 "fancy alert" 弹出框。我多年来一直在我的 Cordova 应用中使用它。

Recently, I've been informed that version 2.1.3 of jQuery has security holes, and I needed to upgrade. The newest version of jQuery that works with jQuery Mobile is 2.2.4. So I have upgraded to 2.2.4, but it breaks my "fancy alert" popup box.

最近,有人告诉我 jQuery 的 2.1.3 版本存在安全漏洞,我需要升级。与 jQuery Mobile 兼容的最新版本是 2.2.4。所以我升级到了 2.2.4,但它破坏了我的 "fancy alert" 弹出框。

Here's my code:

以下是我的代码:

function fancyAppAlert(alertContent){
    if ($("#fancyAlertPopup").length === 0) {
        $(':mobile-pagecontainer').pagecontainer('getActivePage').append('<div style="padding-top: 10px; ' +
            'padding-bottom: 20px; padding-left: 20px; padding-right: 20px; width: 86%" data-role="popup" ' +
            'id="fancyAlertPopup" data-theme="a" class="ui-content"><a href="#&" data-rel="back" ' +
            'class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">' +
            'Close</a><h4 id="fancyAlertText">' + alertContent + '</h4></div>').trigger("create");
    } else {
        $('#fancyAlertText').html(alertContent);
    }
    $("#fancyAlertPopup").popup( "open",{transition: "flip"} );
}

When I use jQuery 2.1.3 the above code pops up an alert window that displays the contents of alertContent. When I use jQuery 2.2.4, the exact same code gives me the following error: Uncaught TypeError: Cannot read properties of undefined (reading 'trigger')

当我使用 jQuery 2.1.3 时,上面的代码弹出一个显示 alertContent 内容的警告窗口。当我使用 jQuery 2.2.4 时,完全相同的代码会导致以下错误:Uncaught TypeError: Cannot read properties of undefined (reading 'trigger')

So clearly it's the .trigger("create") that's breaking it, but I have no idea why. I can find no documentation that mentions any breaking changes between version 2.1.3 and 2.2.4. Does anyone know how to fix this? I cannot upgrade to jQuery 3.x.x because I must have jQuery Mobile 1.4.5, and jQuery 3.x.x does not work with jQuery Mobile 1.4.5.

很明显是 .trigger("create") 导致了问题,但我不知道为什么。我找不到任何文档提到版本 2.1.3 和 2.2.4 之间有任何破坏性更改。有人知道如何修复吗?我不能升级到 jQuery 3.x.x,因为我必须使用 jQuery Mobile 1.4.5,而 jQuery 3.x.x 不与 jQuery Mobile 1.4.5 兼容。

Thanks for any help you can give.

感谢您能提供的任何帮助。

英文:

Years ago, I found this "fancy alert" popup box for use with jQuery mobile. I've been using it in my Cordova apps for years.

Recently, I've been informed that version 2.1.3 of jQuery has security holes, and I needed to upgrade. The newest version of jQuery that works with jQuery Mobile is 2.2.4.
So I have upgraded to 2.2.4, but it breaks my "fancy alert" popup box.

Here's my code:

function fancyAppAlert(alertContent){
	if ($(&quot;#fancyAlertPopup&quot;).length === 0) {
		$(&#39;:mobile-pagecontainer&#39;).pagecontainer(&#39;getActivePage&#39;).append(&#39;&lt;div style=&quot;padding-top: 10px; &#39; +
			&#39;padding-bottom: 20px; padding-left: 20px; padding-right: 20px; width: 86%&quot; data-role=&quot;popup&quot; &#39; +
			&#39;id=&quot;fancyAlertPopup&quot; data-theme=&quot;a&quot; class=&quot;ui-content&quot;&gt;&lt;a href=&quot;#&quot; data-rel=&quot;back&quot; &#39; +
			&#39;class=&quot;ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right&quot;&gt;&#39; +
			&#39;Close&lt;/a&gt;&lt;h4 id=&quot;fancyAlertText&quot;&gt;&#39; + alertContent + &#39;&lt;/h4&gt;&lt;/div&gt;&#39;).trigger(&quot;create&quot;);
	} else {
		$(&#39;#fancyAlertText&#39;).html(alertContent);
	}
	$(&quot;#fancyAlertPopup&quot;).popup( &quot;open&quot;,{transition: &quot;flip&quot;} );
}

When I use jQuery 2.1.3 the above code pops up an alert window that displays the contents of alertContent. When I use jQuery 2.2.4, the exact same code gives me the following error: Uncaught TypeError: Cannot read properties of undefined (reading &#39;trigger&#39;)

So clearly it's the .trigger("create") that's breaking it, but I have no idea why. I can find no documentation that mentions any breaking changes between version 2.1.3 and 2.2.4. Does anyone know how to fix this? I cannot upgrade to jQuery 3.x.x because I must have jQuery Mobile 1.4.5, and jQuery 3.x.x does not work with jQuery Mobile 1.4.5.

Thanks for any help you can give.

答案1

得分: 0

显然,jQuery 2.2.4 与 jQuery Mobile 1.4.5 不兼容。显然,与 jQuery Mobile 兼容的最新版本是 2.1.4。这真的很烦人...

英文:

Well, apparently jQuery 2.2.4 IS NOT compatible with jQuery Mobile 1.4.5. Apparently the latest version of jQuery that's compatible with jQuery Mobile is 2.1.4. That's seriously annoying...

huangapple
  • 本文由 发表于 2023年2月14日 02:23:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75439836.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定