So this is what I want to do:
1) Main page, has 2 "Views"...master and detail
2) When an item in the master list is clicked, load in the detail view and it's model
Sounds easy, but I've been brickwalled on it for the last hour...no idea what to do. Like do I create all my view objects first, then create all my routes...do I call router.start after that, or do I call start then create the other routes...do I need a master layout?...I don't THINK I do, but it's impossible to know from the docs...shouldn't the router load in the right view on navigate, I shouldn't need to call .render() right?
Just baffled, even enhancing the hello world with minor view swapping
6 Answers, 1 is accepted
Router is what keeps an eye on the url and loads the proper views...
router.route(
"/"
,
function
() {
$views.master.render(
"#app"
);
});
router.route(
"/user/:username"
,
function
(username, params) {
$views.detail.render(
"#app"
);
});
So in this case each view will plop itself into <div id="app">
On click of an item in my list I would call
router.navigate(
"/user/"
+ dataItem.Username);
So what happens is my "detail" pane just gets appended below the "master"...so "#app" now has 2 child divs.
I thought the entire concept is that the views are swapped unless I specify a router.append()?
The behavior you describe is by design and documented:
Renders the view contents. Accepts a jQuery selector (or jQuery object) to which the contents will be appended.
If I understand you correctly, the layout showIn method will do what you are expecting (swap one view element with the other).
I am not sure what do you mean by router.append, though. The router does not have such method. Can you please clarify?
Regards,
Petyo
Telerik
Hey Steve,
I know it's over a year ago, but how did you eventually get on with this? I'm always frustrated with Telerik's documentation and again in the case of SPA/View/Layout it was no different and I also found myself completely baffled.
At the moment I'm stuck with another concept: We have a view with a list of quotes and another 4 views which separate out each individual quote into steps in a wizard. Loading the first quote into the wizard Views works fine.
The View object though doesn't have a LoadModel, or ChangeModel method, you can only instantiate the object with the model, if you then wanted a different ViewModel attached to the view it looks like you'll have to re-instantiate the View object along with a new ViewModel.
So what I tried was to create a LoadData method on the actual ViewModel which goes through each of the properties assigning new values using the typical MVVM this.set("myprop", value) syntax. The ViewModel definitely has new data, but the View is never updated.
Again, this leads me to believe that by design you have to instantiate a new View each time you want to attach a new ViewModel to it.
The screenshot attached for an example of what is available on that View object vs. what is documented:
the methods listed in firebug are internal to the SPA implementation and are not meant to be used by the SPA client. This is the reason why they are not documented.
In case you need any assistance with the case you describe, I may suggest that you open a support ticket with a reproducible sample. I am not sure that this forum thread is related to the issue you experience.
Regards,
Petyo
Telerik
My comments in this thread are about your documentation, but I have already started a separate thread here:
http://www.telerik.com/forums/how-do-you-update-the-model-that-the-current-view-is-using