Uncaught TypeError: Cannot call method 'each' of undefined

Moderator: Sisko1990

Forum rules
Forumregeln
Locked
CoAd
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri May 31, 2013 7:41 am

Uncaught TypeError: Cannot call method 'each' of undefined

Post by CoAd » Fri May 31, 2013 8:21 am

Moin Joomlaner,
hab nen Prob mit dem unten aufgelisteten Listing. Mein Browser meldet mir Fehler
"Uncaught TypeError: Cannot call method 'each' of undefined"
Der Fehler taucht in Zeile 5 auf "els[0].each(function(el)"
Kennt sich einer von Euch damit aus???

var sfHover = function(search, replaced) {
if (!replaced) replaced = 'sfHover';
var replacedActive = 'sfActive';
var els = $$('.' + search).getElements('li');
els[0].each(function(el) {
var first = el.getFirst();
if (first) els[0].push(first);
});

var actives = $$('.' + search).getElements('li.active');
if (actives[0] && actives[0].length) {
actives = actives[0];
actives.each(function(active) {
var first = active.getFirst();
if (first) {
first.addClass('active');
var classes = first.getProperty('class').split(" ");
var tmp = [];
for (i = 1, l = classes.length; i<l;i++) tmp.push(classes[0] + '-' + classes[i]);
tmp.push(classes.join('-'));
tmp.each(function(cls) {first.addClass(cls);});
}
});
};

if (!els.length) return false;

els.each(function(el) {
el.addEvents({
'mouseenter': function() {
var classes = this.getProperty('class').split(" ");
classes = classes.filter(function(y) { return !y.test("-" + replaced) && !y.test("-" + replacedActive); });

classes.each(function(cls) { if (this.hasClass(cls)) this.addClass(cls + "-" + replaced); }, this);
var hackish = classes.join("-") + "-" + replaced;
if (!this.hasClass(hackish)) this.addClass(hackish);
this.addClass(replaced);
},
'mouseleave': function() {
var classes = this.getProperty('class').split(" ");
classes = classes.filter(function(y) { return y.test("-" + replaced); });

classes.each(function(cls) { if (this.hasClass(cls)) this.removeClass(cls); }, this);
var hackish = classes.join("-") + "-" + replaced;
if (!this.hasClass(hackish)) this.removeClass(hackish);
this.removeClass(replaced);
}
});
});
};

window.addEvent('domready', function() {
sfHover('menutop');

Sorry für die Darstellung des Listings, hab nicht anders hinbekommen :-[
M.f.G.

 
 
Locked

Return to “Template, CSS und Designfragen”