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

viewModel for a Layout

5 Answers 95 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bart
Top achievements
Rank 1
Bart asked on 24 Jul 2013, 06:35 PM
Why can't a Layout take a viewModel like a View? Something like this:

<div data-role="layout" data-id="service" data-init="init" data-model="viewModel"></div>

As a workaround, I am doing this the following. Is there any reason that I shouldn't be doing this?

<div data-role="layout" data-id="service" data-init="init" data-show="show"></div>

function show() {
  kendo.bind($("service-layout-selector-here"), viewModel);
}

5 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 29 Jul 2013, 07:08 AM
Hi Bart,

Layout view models are not supported purely due to implementation complexity. The layout header and footer are "moved" to the current view DOM element each time the view changes. this would break the mvvm bindings, which rely on a strict DOM hierarchy. 

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bart
Top achievements
Rank 1
answered on 29 Jul 2013, 02:26 PM
OK. Can you give me a recommendation as to the best way to do something like this then?

http://bit.ly/16ur63D

Do I need to repeat this "header" information within each view? Or perhaps I can have two views going at once? One for the header information and another for the body?
0
Petyo
Telerik team
answered on 31 Jul 2013, 12:36 PM
Hi,

If I understand you correctly, I do not think that you need MVVM binding for handling the button group event clicks - you can use declarative event setting instead.

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
David Gerding
Top achievements
Rank 1
answered on 07 Feb 2014, 10:10 PM
Hi,
Is it still the case that there is no straightforward means to use Layout with separate viewModel html files?  Is the real choice "viewModel OR layout widget"?  

Thanks
0
Petyo
Telerik team
answered on 10 Feb 2014, 08:46 AM
Hello David,

my previous response still holds true - ViewModel bindings are not supported for the layout parts. Of course, a view may have both a ViewModel and a layout attached, so I would not consider this an "or" situation. 

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Bart
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Bart
Top achievements
Rank 1
David Gerding
Top achievements
Rank 1
Share this question
or