2013-03-22 76 views
2

我已经拼凑了一些工作了几年的mootools手风琴代码,但突然间我发现firefox打破了它 - safari,chrome或IE中没有问题。firefox only:TypeError:toggler is undefined

http://jordanrossfilms.com

控制台显示:类型错误:toggler这里未定义:

toggler.setStyle( '颜色', '#666');

我想它的东西非常简单,但对于这个新手而言,我不知道是怎么回事?任何帮助?下面完整的代码:

window.addEvent('domready', function() { 
var myAccordion = new Accordion($('accordion'), 'h1.toggler', 'div.element', { 
    display: -1, 
    opacity: true, 
    alwaysHide: true, 
    onActive: function(toggler, element){ 
     toggler.setStyle('color', '#df1a00'); 

     //remove the toggler hover events to clear out its events when it was inactive 
     toggler.removeEvents('mouseenter'); 
     toggler.removeEvents('mouseleave'); 

     //then add your events again 
     toggler.addEvent('mouseenter',function() 
     { 
      //... 
     }); 
    }, 
    onBackground: function(toggler, element){ 
     toggler.setStyle('color', '#666'); 

     //remove the toggler hover events to clear out its events when it was active 
     toggler.removeEvents('mouseenter'); 
     toggler.removeEvents('mouseleave'); 

     //then add your events again 
     toggler.addEvent('mouseenter',function() 
     {this.setStyle('color', '#df1a00'); 

     toggler.addEvent('mouseleave',function() 
     {this.setStyle('color', '#666'); 

     }); 

     }); 
    } 

}); 

变种myAccordion2 =新手风琴($( 'accordion2'), 'h4.toggler', 'div.element2',{ 显示:-1, 不透明度:真, alwaysHide :真, onActive:功能(toggler,元件){ toggler.setStyle( '颜色', '#df1a00');

 //remove the toggler hover events to clear out its events when it was inactive 
     toggler.removeEvents('mouseenter'); 
     toggler.removeEvents('mouseleave'); 

     //then add your events again 
     toggler.addEvent('mouseenter',function() 
     { 
      //... 
     }); 
    }, 
    onBackground: function(toggler, element){ 
     toggler.setStyle('color', '#666'); 

     //remove the toggler hover events to clear out its events when it was active 
     toggler.removeEvents('mouseenter'); 
     toggler.removeEvents('mouseleave'); 

     //then add your events again 
     toggler.addEvent('mouseenter',function() 
     {this.setStyle('color', '#df1a00'); 

     toggler.addEvent('mouseleave',function() 
     {this.setStyle('color', '#666'); 

     }); 

     }); 
    } 

}); 

var myAccordion = new Accordion($('accordion3'), 'h5.toggler', 'div.element3', { 
    display: -1, 
    opacity: true, 
    alwaysHide: true, 
    onActive: function(toggler, element){ 
     toggler.setStyle('color', '#df1a00'); 

     //remove the toggler hover events to clear out its events when it was inactive 
     toggler.removeEvents('mouseenter'); 
     toggler.removeEvents('mouseleave'); 

     //then add your events again 
     toggler.addEvent('mouseenter',function() 
     { 
      //... 
     }); 
    }, 
    onBackground: function(toggler, element){ 
     toggler.setStyle('color', '#666'); 

     //remove the toggler hover events to clear out its events when it was active 
     toggler.removeEvents('mouseenter'); 
     toggler.removeEvents('mouseleave'); 

     //then add your events again 
     toggler.addEvent('mouseenter',function() 
     {this.setStyle('color', '#df1a00'); 

     toggler.addEvent('mouseleave',function() 
     {this.setStyle('color', '#666'); 

     }); 

     }); 
    } 

}); 

});

回答

2

我看到你正在使用mootools 1.2 mootools最近发布了一个修复1.2导致Firefox的错误,因为新的firefox和mootools与String.concat相撞。

你可以看到一个关于它的Blog Post。 无论如何尝试更新到新的1.2版本,看看它是否解决了问题

+0

刚刚尝试过,并且网站在所有浏览器中完全中断。火狐显示了这个错误:的ReferenceError:未定义手风琴 的ReferenceError:手风琴没有定义 \t VAR myAccordion =新的手风琴($( '手风琴'), 'h1.toggler', 'div.element',{ – user2199976 2013-03-22 16:45:16

+1

手风琴在mootools中定义更多[http://mootools.net/more125](http://mootools.net/more125)。你是否下载过它?检查以前在mootools和dl中使用过的东西 – Adidi 2013-03-22 16:49:16

+0

是的!谢谢!在所有元素中加入更多的元素,并且再次运作 – user2199976 2013-03-22 18:23:17