Mootools accordion with a Next button inside each pane

最后都变了- 提交于 2019-12-11 02:31:54

问题


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.

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
    });
});

Many thanks!! Dan


回答1:


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);
});

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



来源:https://stackoverflow.com/questions/14271551/mootools-accordion-with-a-next-button-inside-each-pane

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!