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

Dynamically load View with Layout

1 Answer 169 Views
View
This is a migrated thread and some comments may be shown as answers.
Kent
Top achievements
Rank 1
Kent asked on 27 Aug 2014, 02:22 AM
How do you dynamically load a view and layout?  I can get the view to work by itself, but not a view with layout.  I created the simple example below to illustrate the issue.  The only way I can make this work is to place the layout in the index.html file, which means it's not dynamically loaded at runtime.

// insert view
$('body').append("<div data-role='view' id='view2' data-layout='main'>This is view2</div>")

// insert layout
$('body').append("<div data-role='layout' data-id='main'><header data-role='header'>Header</header><!-- application views will be rendered here --><footer data-role='footer'>Footer</footer></div>");

// display view
app.navigate('#view2');

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 27 Aug 2014, 10:20 AM
Hi,

Unlike views, layouts are parsed and instantiated when the mobile application is instantiated. In case you load these contents from another resource, you may use remote views instead - if the response contains a layout definition, it will be parsed and applied. 

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