framework7

Open full view…

Load/initialise view with page content?

Shaun Byrnes
Thu, 18 Dec 2014 22:05:43 GMT

I have some empty tab views in the main page index.html, which I would like to leave empty and have them load content from their respective pages when the views are added with addView() I tried view.router.loadPage('path/to/tab/page.html') which does load in a page, but it has added the page to the stack (with history, back etc), rather than replacing the empty view container with the correct template. Would it be possible to add a "pageUrl" property or something of the sort to the addView() method, so when a view in the DOM is targeted, we can provide a url for the actual content which should be loaded into it? // Empty shell in index.html page <div id="view-home" class="view view-main tab active"> </div> <div id="view-about" class="view tab"> </div> // Add views and point to the respective content which should be initialised into the containers myApp.addView('#view-home', { pageUrl: 'components/home/home.html' }); myApp.addView('#view-about', { pageUrl: 'components/about/about.html' });

Shaun Byrnes
Thu, 18 Dec 2014 22:12:53 GMT

It seems like we almost have this with loadContent(), but I want to load an actual template page if possible :)

Shaun Byrnes
Wed, 14 Jan 2015 09:22:49 GMT

bump

Vladimir Kharlampidi
Wed, 14 Jan 2015 16:03:05 GMT

When you initialize View it SHOULD have full pages structure. But you may keep it with empty dummy page, for example: --- <div class="view"> <div class="pages"> <div class="page" data-page="dymmy-page"></div> </div> </div> --- And then when you init View with addView you may just call reload method right after: --- var view = app.addView('.view'); view.reloadPage('...url to page...');

Shaun Byrnes
Fri, 16 Jan 2015 02:18:02 GMT

Hey mate, thanks for the tip! Works perfectly! :)