【问题标题】:mootools accordion not workingmootools 手风琴不工作
【发布时间】:2011-05-30 11:52:16
【问题描述】:

我一直想在mootools上试试手风琴效果但是我不能让它工作,就像js根本没有加载一样

这是 HTML 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
 <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <title>BarDiJan - We Deliver</title> 
    <link rel="stylesheet" href="/stylesheets/reset.css" type="text/css" /> 
    <link rel="stylesheet" href="/stylesheets/style.css" type="text/css" /> 
    <script type="text/javascript" src="/javascripts/mootools-core-1.3-accordion.js"></script> 
    <script type="text/javascript" src="/javascripts/mootools-more.js"></script> 
    <script type="text/javascript" src="/javascripts/application.js"></script> 
 </head> 

<body>
    <div class="container"> 
    <div id="accordion"> 
  <h3 class="toggler">What we Do</h3> 
  <div class="element"> 
    <p>We are people who deliver professional quality identity to you, we have wide range of support.
    </p> 
  </div> 
  <h3 class="toggler">What we Did</h3> 
  <div class="element"> 
    <p>Under Construction</p> 
  </div> 
  <h3 class="toggler">What we Offer</h3> 
  <div class=""> 
    <ul> 
    <li>Web Design</li> 
    <li>Identity</li> 
    </ul> 
  </div> 
</div> 


    </div> 

  </body> 
</html> 

这是 application.js 代码

windows.addEvent('domready', function() {

var accordion = new Accordion($$('h3.toggler'),$$('div.element'), {
    display: 2,
    opacity: false,
    alwaysHide: true,
    onActive: function(toggler) { toggler.setStyle('color', '#929292'); },
    onBackground: function(toggler) { toggler.setStyle('color', '#000000'); }
  });
});

我做错了什么吗?如果这很重要,我也会使用 sinatra。

也感谢您的宝贵时间。 . .

【问题讨论】:

    标签: javascript ruby mootools sinatra javascript-framework


    【解决方案1】:

    您忘记将element 类添加到最后一个元素。

    这是一个有效的 jsfiddle:http://jsfiddle.net/arian/YqNuh/

    【讨论】:

    • 你能告诉我要放入什么库吗?我已经有了 mootools 核心,但我似乎无法正确获取更多库,即使我已经包含了 fx.accordion。 .
    • 如果你已经有 -core,包括 Fx,这个 -more 构建应该可以做到:mootools.net/more/cbf2909f532bfaecd87d1f6d8da99cb8(只有 Fx.Elements 和 Fx.Accordion)。
    【解决方案2】:
    windows.addEvent('domready', function() {... 
    

    你犯了一个错误,window,而不是 windows ;-) 所以:

    window.addEvent('domready', function() {... 
    

    【讨论】:

      猜你喜欢
      • 2012-10-07
      • 2016-06-22
      • 1970-01-01
      • 2014-12-15
      • 1970-01-01
      • 2016-09-02
      • 2014-10-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多