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

Rendering or Appending a View in a Container

7 Answers 268 Views
SPA
This is a migrated thread and some comments may be shown as answers.
mgs
Top achievements
Rank 1
mgs asked on 04 Mar 2013, 09:07 AM
Reading http://docs.kendoui.com/getting-started/framework/spa/view I understand that the "render" method renders a view inside a container by replacing the current content with the new content.

However, when testing, I did not see that behaviour. Actually on "render" the view is appended to the current content, inside the wrapping "div" element.

Michael G. Schneider

7 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 04 Mar 2013, 01:30 PM
Hi Michael,

The behavior you describe (replacement of content) is a responsibility of the showIn method of the layout.

Can you please point us to the part in the documentation that states otherwise (or somehow implies) that the view render method replaces the container contents? I re-read it, and I think that we have used 'append' to describe what happens. Most probably I am missing something.

Thank you in advance,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

0
mgs
Top achievements
Rank 1
answered on 04 Mar 2013, 02:07 PM
Hello Petyo,

thanks a lot for the answer. English not being my first language I should not try to proofread a text.

I once again read that topic. I think my assumption came from the following.

  • There is a chapter "Appending View Element". So if there is a way for appending the view, the "render" call will probably replace the contents.
  • In the chapter "Appending View Element" the sentence below the source code starts with "Subsequent reder calls will not re-instantiate ... but append ...". This sentence would make sense, if it had appeared in the previous chapter "Rendering View in a Container". So I did not take it serious, and thought it should have read "Subsequent append calls...".
Michael G. Schneider
0
Petyo
Telerik team
answered on 05 Mar 2013, 10:08 AM
Hello Michael,

Thank you for your input - I have re-ordered the docs as per your suggestion. This should hopefully save some confusion for our users.

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!
0
mgs
Top achievements
Rank 1
answered on 05 Mar 2013, 01:56 PM
Hello Petyo,

thanks a lot for the answer. The change to the documentation is only internal, it is not yet visible for the public. Or should I see it?

Michael G. Schneider
0
Petyo
Telerik team
answered on 07 Mar 2013, 09:28 AM
Hi Michael,

The change is yet to be published on the docs site - you can follow the changes in the master branch of the kendo-docs github repository

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!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 25 Jun 2013, 07:39 PM
@Michael

Did you ever get this to work?  I also just noticed "render" on a view was appending into the container.

I don't understand the layout and view concepts maybe?  Why do we need both?

Is layout the like "Masterpage" and the views are the "ContentPlaceholders\pages"?

Steve
0
mgs
Top achievements
Rank 1
answered on 26 Jun 2013, 06:37 AM
Hello Steve,

if I remember correctly, the problems that I discussed in this post were caused by me misunderstanding  the initial version of the documentation. There were no real problems with Kendo SPA. So yes, I made it work.

I prepared two small samples, showing some basics. One sample is without a layout, and the other one uses a layout. You can find them here...

Without a layout: http://jsfiddle.net/mgs_jsfiddle/w6dhf/
With a layout: http://jsfiddle.net/mgs_jsfiddle/RtAeB/

Using a layout brings the benefit that you can have several areas, where content can be placed into. Not using a layout causes the content to be added to the container, whereas using a layout always replaces the container's content.

I think that "adding / replacing" is no natural consequence of "without layout / with layout". With SPAs you probably always want a "replace". So if not using the layout you have to remove the previous content before the render-call.

I always use "with layout", even if there is just a single area to be rendered.

Michael G. Schneider
Tags
SPA
Asked by
mgs
Top achievements
Rank 1
Answers by
Petyo
Telerik team
mgs
Top achievements
Rank 1
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or