Wijmo UI for the Web
KO Accordion Binding
Wijmo User Guide > Concepts > Integrating Frameworks > Knockout > Two-Way Live Binding > KO Accordion Binding

Data-binding options:

Example:

In this example, the ViewModel is defined specifically for use with the accordion. It has disabled, requireOpenedPane and selectedIndex properties that are bound in the View. If any of these values change, then the widgets automatically respond to them. The widgets also update the ViewModel values as they modify them. For example, as the user clicks to select different panes, the selectedIndex value in the ViewModel updates automatically.

Create a ViewModel:

ViewModel Script
Copy Code
var viewModel = function () {
      var self = this;
      self.disabled = ko.observable(false);
      self.requireOpenedPane = ko.observable(false);
      self.selectedIndex = ko.observable(0);
};

Create View with bound controls:

View Markup
Copy Code
<div data-bind="wijaccordion: {

    disabled: disabled, 

    requireOpenedPane: requireOpenedPane, 

    selectedIndex: selectedIndex}">
    <div>
        <h3>
            <a href="#">First</a></h3>
        <div>
            <p>
                First Pane
            </p>
        </div>
    </div>
    <div>
        <h3>
            <a href="#">Second</a></h3>
        <div>
            <p>
                Second Pane
            </p>
        </div>
    </div>
</div>
See Also

Widgets

Concepts

Reference