本文介绍了Mootools手风琴在每个窗格中都有一个“下一步"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在手风琴导航设备的所有窗格中添加一个下一步"按钮.如您所料,单击下一步"按钮时,当前窗格将折叠,而下一个窗格将打开.

I'd like to add a Next button to all (well... all except the last) panes of an accordion navigation device. As you'd expect, when you click the Next button, the current pane collapses and the next one opens.

它在Joomla网站上,因此我们正在使用MooTools.我无法使click事件的操作生效.有什么想法吗?

It's on a Joomla site, and so we're using MooTools.I'm having trouble getting the action of the click event to work. Any thoughts?

window.addEvent('domready', function() {
var accordion = new Fx.Accordion($$('#accordion h2'),$$('#accordion .content'), {
    onActive: function(toggler,element) { toggler.addClass('active');element.addClass('active'); },
    onBackground: function(toggler,element) { toggler.removeClass('active');element.removeClass('active'); }
});

$$('.button.next').addEvent('click', function(event){
      event.stop();
      accordion.display.getNext(); //HELP HERE PLEASE
    });
});

非常感谢!!丹

推荐答案

console.log(accordion)中检查您的手风琴实例;)尝试访问手风琴实例的previous属性.它没有记录,并且可能随MooTools More的未来版本而改变,但这是完成所需操作的最简单方法:

Inspect your accordion instance in console.log(accordion) ;) Try accessing previous property of accordion instance. It doesn't documented and may change with future versions of MooTools More, but it is the easiest way to do what you want:

$$('.button.next').addEvent('click', function(event){
    event.stop();
    accordion.display(accordion.previous + 1);
});

在这里工作的小提琴: http://jsfiddle.net/9859J/

Working fiddle here: http://jsfiddle.net/9859J/

这篇关于Mootools手风琴在每个窗格中都有一个“下一步"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 02:20