#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    8
    Rep Power
    0

    JQuery 1.7.2 Browser compatibility


    Hi,

    a website uses JQuery 1.7.2 because of the usage of older code that does not work with 1.8 or higher.

    Now I have to add just a small portion of code. I have to trigger some action when link in a navigation bar are clicked on.

    The following code causes no effect in Safari and Chrome:

    Code:
    jQuery(document).ready(function($){
      $('li.filter a').click(function() { 
        alert('click');
      });
    });
    How could I make it compatible? Thanks in advance.

    -- Micha
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    237
    Rep Power
    29
    At first glance I see no problems in this code.

    And JQuery is cross-browser enough. Especially suspicious is that you have problems with Chrome.

    Perhaps your other code makes script fail?

    Did you debug this? How much results this selector "$('li.filter a')" returns on its call?

    Or perhaps you are updating this block later (with ajax) and "click" handler is removed?
    CodeAbbey - programming problems for novice coders
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    8
    Rep Power
    0
    I exclude interferences with the other scripts because Firefox is acting as expected.

    This selector returns multiple result because this action is triggered for every item in that navigation bar.

    I'm thinking about other way to detect clicks on the navigation list but still figure out which element was clicked on.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    8
    Rep Power
    0
    Chrome shows random reaction on that code. It does not depend on reloading or clearing the cache.

IMN logo majestic logo threadwatch logo seochat tools logo