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

Binding ViewModel Methods to data-show

2 Answers 193 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
d2uX
Top achievements
Rank 1
d2uX asked on 10 Jul 2012, 09:16 AM
Hi there,

slowly getting used to this MVVM thing but I still have some problems.

I set up my viewmodel as a kendo.observable and also set a datasource and a method:
var orderViewModel = kendo.observable({
    orderList: orderDS,
    showOrderDetail: function(e) {
        var view = e.view;
     
        orderDS.fetch(function() {
            var model = view.model,
                item = orderDS.get(view.params.id);
            model.set("order", item)
        });
    }
});

My orders (the list) is displayed without any problem (tho it took me some time to accomplish that) 
Now I'm trying to display the corresponding details for each order in my detailsView:
<div
    id="orderDetail"
    data-role="view"
    data-layout="mobile-tabstrip"
    data-title="Orders"
    data-model="orderViewModel"
    data-show="showOrderDetail"
>
    <p data-bind="text: order.total"></p>
</div>

Nothing happens...
When I am moving the showOrderDetail out of my viewmodel (as function showOrderModel(e){ ...} everything works.
But I want to capsule the corresponding functions of a model (which is showing details) into that model. Or am I missing sth?

Hope someone can point me into the right direction.
Thx

2 Answers, 1 is accepted

Sort by
0
pedro
Top achievements
Rank 1
answered on 13 Feb 2013, 03:02 PM
I have the same problem!!! Can someone from Telerik please help.
0
Petyo
Telerik team
answered on 15 Feb 2013, 08:21 AM
Hello,

You may specify the data-show event handler using the full path to the viewModel method - 

  data-show="orderViewModel.showOrderDetail"

Kind regards,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
d2uX
Top achievements
Rank 1
Answers by
pedro
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or