2008-09-17 2 views
1

У меня есть этот код в jQuery, который я хочу переопределить библиотекой прототипов.Как я могу переопределить внешний всплывающий код jQuery в Prototype?

// make external links open in popups 
// this will apply a window.open() behaviour to all anchor links 
// the not() functions filter iteratively filter out http://www.foo.com 
// and http://foo.com so they don't trigger off the pop-ups 

jQuery("a[href='http://']"). 
     not("a[href^='http://www.foo.com']"). 
     not("a[href^='http://foo.com']"). 
     addClass('external'); 

jQuery("a.external"). 
     not('a[rel="lightbox"]').click(function() { 
     window.open(jQuery(this).attr('href')); 
     return false; 
}); 

Как можно итеративно отфильтровать коллекцию элементов с помощью эквивалентной к не() операторы, перечисленные здесь в JQuery?

ответ

4

Фильтрация может быть сделано с помощью метода отвергают как так:

$$('a').reject(function(element) { return element.getAttribute("href").match(/http:\/\/(www.|)foo.com/); }).invoke("addClassName", "external");