Does jQuery.not selector work with .delegate?

I am trying to make an Ajax call on all <a>elements inside id #filterthat do not have a class .noAjax, and somehow I cannot get it to work. can anyone take a look at my syntax please?

$("#filter").not($("a.noAjax")).delegate("ul#portfolio-list li a", "click", function() {
    if ($.browser.msie) {
        location.hash = "#/" + this.pathname;
    } else {
        location.hash = this.pathname;
    }
    return false;
});

when I try to just use aor a.ajax(which, of course, is added before the attempt) as a selector for .delegate, nothing works at all. with jquery ajax works, but it tries to load the content even when I click the link witha.noAjax

+3
source share
3 answers

Use instead :not():

$("#filter").delegate("ul#portfolio-list li a:not(.noAjax)","click",function() {
    if ($.browser.msie) {
        location.hash = "#/" + this.pathname;
    } else {
        location.hash = this.pathname;
    }
    return false;
});

ul, :

$("#portfolio-list").delegate("li a:not(.noAjax)", ...);
+10

:

$("#filter").not($("a.noAjax")).

a, :

$("#filter a").not("a.noAjax")

, :

$("#portfolio-list").delegate("li a:not(.noAjax)", "click", function() 
0

Try changing the first part to this:

$("#filter a").not($(".noAjax")).del...

Another way will select all elements in #filterwhich are not a.noAjax(including tags that do not contain anchors).

0
source

Source: https://habr.com/ru/post/1775662/


All Articles