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

Very confused where to start...

6 Answers 140 Views
SPA
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 05 Jun 2014, 04:18 PM
Demos and docs are WILDLY incomplete.  Great we have demo apps, but you can't load them into the dojo and there's no tutorials on how they were built.  The docs have a basic hello world, but it's one view...and all of the concepts are segregated into sub pages.

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

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 05 Jun 2014, 05:30 PM
Assumptions:

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()?
0
Petyo
Telerik team
answered on 09 Jun 2014, 02:07 PM
Hello Steve,

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jacques
Top achievements
Rank 2
answered on 19 Oct 2015, 03:49 PM

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.

0
Jacques
Top achievements
Rank 2
answered on 20 Oct 2015, 01:28 PM

The screenshot attached for an example of what is available on that View object vs. what is documented:

 

 

0
Petyo
Telerik team
answered on 21 Oct 2015, 07:52 AM
Hi Jacques,

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jacques
Top achievements
Rank 2
answered on 21 Oct 2015, 09:16 AM

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

 ​

Tags
SPA
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Petyo
Telerik team
Jacques
Top achievements
Rank 2
Share this question
or