Model binding for data-role="layout"

3 posts, 1 answers
  1. Bogdan
    Bogdan avatar
    2 posts
    Member since:
    Feb 2014

    Posted 21 Feb 2014 Link to this post

    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. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 24 Feb 2014 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Bogdan
    Bogdan avatar
    2 posts
    Member since:
    Feb 2014

    Posted 24 Feb 2014 in reply to Alexander Valchev Link to this post

    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();
                }
    }
Back to Top