Giter Site home page Giter Site logo

awps / accordion.js Goto Github PK

View Code? Open in Web Editor NEW
40.0 4.0 11.0 90 KB

Accordion.JS: Free jQuery Accordion plugin

Home Page: https://accordion.js.org

License: MIT License

CSS 8.27% JavaScript 83.63% Less 8.10%
jquery-plugin smk-accordion javascript accordion accordionjs toggle collapse

accordion.js's People

Contributors

awps avatar tkfv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

accordion.js's Issues

Please document how to open/close sections programmatically

It would be really helpful to have a bit in the docs which explains how to use this library to programmatically open/close sections. I have worked out a way to do it, but I'm not sure if there's a better way which the library expects.

Note, I've found that when you programmatically open a section, other open sections do not close, even if closeOther is set to true. (Not sure whether this is a bug, though.)

For the curious, here's my solution:

    // Initialize the accordion
    jQuery(document).ready(function($){
        $("#my-accordion").accordionjs({
          activeIndex : false,
          openSection: myOpenAccordionSection,
        });

and then later, close open sections and open another:

      var newSection = $("#my-inner-content")[0].closest('.acc_section');
      var acc = $('.accordionjs').accordionjs({activeIndex: false});

      // Close all open sections which aren't the one that's been selected
      acc.closeOtherSections($(newSection), 0);

      // Open the selected section only if it isn't already
      if (! $(newSection).hasClass('acc_active')) {
        acc.openSection($(newSection), 0);
      }

NB: You have to pass things like "activeIndex" again when you re-instantiate the accordion to call methods on it. The alternative, I guess, is to put them in the HTML as data- attributes or to store the original variable instantiated in document.ready.

And for those Googling, this will not work because you haven't called accordionjs() on it:

var newSection = $('#my-inner-content')[0].closest('.acc_section');
$(".accordionjs").openSection($(newSection), 0);

This throws Uncaught TypeError: $(...).openSection is not a function.

Nested accordion issue

Hi,
Thanks for the develop this plugin.. It's really cool. I faced a issue when I used closeAble: true with nested accordion. Actually what happen was, nested accordion open and close when it click. How I fix this. Please help me.

Thanks!!

Disable scroll

When we click on heading it scrolls to upward direction. Can we disable this?

Uncaught TypeError: t.slideDown is not a function

Sample code/html exactly as per docs doesn't run:
Uncaught TypeError: t.slideDown is not a function
at w.fn.init.openSection (accordion.min.js:1)
at w.fn.init.create (accordion.min.js:1)
at i (accordion.min.js:1)
at w.fn.init.e.fn.accordionjs (accordion.min.js:1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.