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

Model binding for data-role="layout"

2 Answers 208 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Bogdan
Top achievements
Rank 1
Bogdan asked on 21 Feb 2014, 08:18 PM
Is it possible to use model binding on layouts? We have a header navbar in the layout and we need a custom back button for some views that get loaded into the layout.

Is there a way to use binding in a layout or some other way of tackling this problem using the MVVM way?

I have tried using layout show events and such to try to bind a layouts viewModel to the layout programmaticaly. It did not seem to work.

We are using Kendo UI Mobile in AppBuilder.

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 24 Feb 2014, 09:23 AM
Hi Bogdan,

Using MVVM bindings inside the layout is no supported out of the box. In this blog post you can learn more about this limitation and to find a possible workaround.
On a side note, there is no need to use MVVM in order to hide a button in the layout. Please check this forum thread for a possible solution that does not involve MVVM.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bogdan
Top achievements
Rank 1
answered on 24 Feb 2014, 02:15 PM
Thank you for clearing that up Alex!

I ended up using the layouts show event combined with the view model of the current view. Almost MVVM ;)

function setBackButton(e) {
            var backButton = $('.back-button');
            if (e.view.model.backTo) {
                backButton.show();
                backButton.attr('href', '#' + e.view.model.backTo);
            } else {
                backButton.hide();
            }
}
Tags
MVVM
Asked by
Bogdan
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Bogdan
Top achievements
Rank 1
Share this question
or