This is a migrated thread and some comments may be shown as answers.

Binding buttongroup select event to a viewModel function

1 Answer 212 Views
ButtonGroup
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 26 Jun 2013, 07:50 PM
I'm having trouble binding the select event of a buttongroup to a method of the viewModel.

Typically, this would look something like this:

    <div>
        <ul class="location-type-buttons" data-role="buttongroup" data-index="0" data-bind="...">
            <li>Option 1</li>
            <li>Option 2</li>
            <li>Option 3</li>
            <li>Option 4</li>
        </ul>
    </div>

    <div style="position: relative;-webkit-box-flex: 1;border: 1px solid black">
        <div data-role="view" style="position: absolute;">Option 1 Title</div>
        <div data-role="view" style="position: absolute;">Option 2 Title</div>
        <div data-role="view" style="position: absolute;">Option 3 Title</div>
        <div data-role="view" style="position: absolute;">Option 4 Title</div>
    </div>

When I use data-bind="click: doSelect", the views appear correctly but nothing happens (the buttongroup has a select event instead of a click event).

When I use data-bind:"select: doSelect", the titles of the four views appear simultaneously, and the event handler is still not called.

What am I missing here?  Thanks!

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 28 Jun 2013, 04:48 PM
Hi Robert,

I am afraid that your scenario is a bit unclear. If I understood correctly you would like to navigate between Views through a button group. If that is correct, please check this sample as it demonstrates one possible implementation of such scenario:

Please note that the right binding syntax is: data-bind="events: { select: onSelect }"

I hope the information will help.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ButtonGroup
Asked by
Robert
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or