简体   繁体   English

单击其他href后href的onclick中断

[英]href's onclick breaks after other href is clicked

I am using jquery mobile in a cordova app. 我在cordova应用中使用jquery mobile

I have multiple links (jquery mobile buttons), some of which follow a normal href link, others call some code in onclick . 我有多个链接(jquery移动按钮),其中一些遵循普通的href链接,其他则在onclick调用某些代码。

When pressing my buttons making use of onclick , they work for multiple presses . 当使用onclick按下我的按钮时,它们可以多次按下。 I can press them multiple times, each time envoking the code. 我可以多次按下它们,每次都调用代码。

However, when I press on of my buttons with a normal href link, my buttons making use of onclick seems to break. 但是,当我按下带有常规href链接的按钮时,使用onclick按钮似乎onclick了。 The moment I press a button following a normal href link, my other onclick buttons stop working. 当我在常规href链接上按下按钮时,其他onclick按钮就会停止工作。

It is worth noting that my buttons making use of onclick , also NEVER shows the "pressed" animation that jquery mobile adds when clicked. 值得注意的是,我的按钮使用了onclick ,也从不显示jquery mobile在单击时添加的“按下”动画。 The normal href buttons ALWAYS shows the "pressed" animation when clicked. 正常的href按钮在单击时始终显示“按下”动画。

My links all navigate to outside of the app, either activating an intent, or navigating to an external website using InAppBrowser . 我的所有链接都导航到应用程序外部,既可以激活意图,也可以使用InAppBrowser导航到外部网站。 The normal href buttons always works. 正常的href按钮始终有效。

I have tried to reload the page in place when a button is clicked, but this does not work. 单击按钮后,我尝试重新加载页面,但这不起作用。

 $("#ctel").on('click', function (e) {

      $.mobile.changePage("#businessCard");

 });

My links: 我的链接:

<a href="tel:x" id="ctel" class="ui-btn ui-icon-phone ui-btn-inline ui-btn-icon-notext ui-corner-all"></a>
<a href="mailto:x" id="cmail" class="ui-btn ui-icon-mail ui-btn-inline ui-btn-icon-notext ui-corner-all"></a>
<a href="#" id="cbookings" class="ui-btn ui-icon-calendar ui-btn-inline ui-btn-icon-notext ui-corner-all" onclick="window.open('link', '_system');"></a>
<a href="#" id="cwebsite" class="ui-btn ui-icon-home ui-btn-inline ui-btn-icon-notext ui-corner-all" onclick="window.open('link', '_system');"></a>

As @Sithys was suggesting, I actually did have an error not relating directly to the jquery mobile buttons. 正如@Sithys所暗示的,实际上我确实有一个与jquery移动按钮不直接相关的错误。 I was re-writing my url's to point to another stats url, from which it then redirected to the appropriate url. 我正在重新编写自己的网址,以指向另一个统计资料网址,然后从该网址重定向到相应的网址。

It seems some of the intents did not like this redirect, and probably caused an undesired effect/error somewhere in the android/cordova eco system. 似乎有些意图不喜欢这种重定向,并且可能在android / cordova生态系统中的某处引起了不希望的效果/错误。 I removed the stats url, and by implication the redirect to the intent, and all is working as it should. 我删除了统计网址,并暗示重定向到该意图,并且一切都按预期进行。

Strangely, I did however test this in Ripple emulator, and there it works perfectly fine with the stats tracking url and redirect. 奇怪的是,我确实在Ripple模拟器中对此进行了测试,并且它与统计信息跟踪url和重定向完全兼容。

I ended up doing a manual ajax post to track my clicks, and just activated the intents as per normal. 我最终做了一个手动ajax发布来跟踪我的点击,并按照正常方式激活了意图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM