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');
// 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');