Implementation of an accordion menu for Titanium apps. Currently only tested on Android. This repo is a demo app, the only file you need to paste into your project is "app/lib/accordion.js".
-
Create a container view for the menu items, and set the attribute "accordion" to "true":
<View id="myView" accordion="true"> ... </View>
OR...
var view = Titanium.UI.createView( {accordion: "true", id: "myView"} );
-
Add elements to the container. The first child element will be assigned the click event handler, and the rest of the children will be hidden when the accordion is collapsed.
-
Import the module:
var accordion = require("accordion");
-
Initialize your view
$.window.open();
-
Run the module:
var depth = -1; // no max tree search depth var startCollapsed = true; // initial accordion state is collapsed var root = $.window // this can be element that is a parent of the $.myView function callback (containerView) {}; // called when an accordion menu is toggled accordion.setup(root, depth, startCollapsed, callback);