简体   繁体   English

jQuery .bind('click.select')在移动设备中不起作用

[英]jquery .bind('click.select') is not working in mobile

So I have this code that whenever a page is onLoad, the user is not able to click any of the links unless it has finished loading the page in a specific region. 因此,我有这段代码,每当页面处于onLoad状态时,用户就无法单击任何链接,除非它已完成了在特定区域中的页面加载。

// note: this events are for the specific li tags of this.ui.liLink
'events' : {
    'click @ui.catalogTab'      : 'showCatalogsTabView',
    'click @ui.transcriptTab'   : 'showTranscriptsTabView',
    'click @ui.facilitationTab' : 'showFacilitationTabView'
},
'ui' : {
    'liLink' : '.catalog-menu > ul > li'
},

'enableTabClick' : function () {
    this.ui.liLink.removeClass( 'disabled' );
    this.ui.liLink.unbind( 'click.select' );
},

'disableTabClick' : function () {
    this.ui.liLink.addClass( 'disabled' );
    this.ui.liLink.bind( 'click.select', false );
}

this is working perfectly on desktop but when I use it on mobile devices, .bind() is not working and does not disable the event listener for click events. 这在台式机上运行良好,但是当我在移动设备上使用它时,.bind()无法正常工作,并且不会禁用单击事件的事件侦听器。 How do I do it on mobile? 如何在移动设备上进行?

So I finally solved my problem. 所以我终于解决了我的问题。 In mobile, the event you have to listen for is touchstart. 在移动设备中,您必须听的事件是touchstart。 So I added it to my current code. 所以我将其添加到当前代码中。

    'enableTabClick' : function () {
        this.ui.liLink.removeClass( 'disabled' );
        this.ui.liLink.unbind( 'click.select touchstart' );
    },

    'disableTabClick' : function () {
        this.ui.liLink.addClass( 'disabled' );
        this.ui.liLink.bind( 'click.select touchstart', false );
    },

It may be because in mobile devices there are not such events "click". 可能是因为在移动设备中没有此类事件“单击”。 Try mobile events - "tap" or "drag" for example. 尝试移动事件-例如“轻按”或“拖动”。 I think that problem in it. 我认为其中存在问题。

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

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