jQuery。点击<a> not getting triggered on a mobile device

时间:2015-11-05 13:35:26

标签: javascript android jquery ios mobile

I have a dropdown menu for changing the language. In order to do that I need to react to the OnClick event and trigger my own code, so I have the following jQuery :

$(document).ready(function() {
    $(".user-info-menu .dropdown-menu a").click(function(e) {
           var $this = jQuery( this ),
           lang_code = $this.data( 'lang' ); // for this you need to add an attribute data-lang="nl" for each A href link

           // Display a notification or loading indicator
           show_loading_bar(90); 

           $.post ('/i18n/setlang/', {
             csrfmiddlewaretoken: csrftoken,
             lang: lang_code,
             language: lang_code
           }).done(function(response){
             show_loading_bar(100);
             window.location.reload();
           });
    });
});

Now ... this seems to be working perfectly on desktop browsers, but as soon as I try it on my iPhone / iPad or android tablet, it doesn't seem to be working at all. For some reason the .click doesn't get triggered.

I've already tried many things I found on the web (touchstart, vclick, tap, ... ) but sadly haven't been able to get it working.

Any suggestions ?

0 个答案:

没有答案