JQUERY ELEMENTS ALWAYS BLOCK

Monaj Singh

Total Post:41

Points:287
Posted by  Monaj Singh
 1163  View(s)
Ratings:
Rate this:
Hi Guys

I have created Safari Extension that blocks certain elements from Facebook and I was wondering is it possible to make it block all the time. For example, it blocks the elements when you load Facebook, however when you click the Facebook logo in the top left corner all the elements come back, you have to manually reload the page to block them again. So basically all the elements come back when you click something that doesn't reload the page.Please help me

Here is my code.

jQuery(document).ready(function () {

      $("#content").find("#sideNav").find("#listsNav").css("display", "none");

});

  1. Hugh Jackman

    Post:52

    Points:366
    Re: Jquery elements always block

    It all depends on what facebook actually does when you click the logo.

    If it makes an AJAX request, then you can listen for that event and re-hide the elements then.

    For example:

    $(document).ajaxComplete(function () {

        $("#content").find("#sideNav").find("#listsNav").css("display", "none");

    });

    If it just runs some local javascript then you could listen for the click event, and again run your code. For example, assuming the logo has an id of #logo

    $("#logo").click(function () {

        $("#content").find("#sideNav").find("#listsNav").css("display", "none");

    });

    In addition, as suggested by Satpal, ids are meant to be unique to a page so you don't need to find them the hard way, just reference them directly like so:

    $("#listsNav").hide();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!