Dynamic Template 7 Pages
This is a (multiple allowed):
-
[x] bug
-
[ ] enhancement
-
[ ] feature-discussion (RFC)
-
Framework7 Version: Framework7 2.0.0-beta.17
-
Platform and Target: Cordova
What you did
I am trying to port my app to V2 in prep for the stable release however I cant seem to get the template data to show on the page loaded via the new router process.
Previous Code Set
//Intialise the Framework7 framework with its required settings.
var myApp = new Framework7({
swipePanel: 'left',
template7Pages: true,
template7Data: {
'url:results.html': {
promo: '',
retail: '',
save: '',
imagelink: ''
}
}
});
var mainView = myApp.addView('.view-main')
/* A whole prep process i.e. global and function specific variables + multiple ajax calls exists here */
//set the result data for result page to view
Template7.data = {
'url:results.html': {
promo: price,
retail: retail,
save: discount,
imagelink: prodimage
}
}
//Hide the loader
myApp.hidePreloader();
//Show the results page
mainView.router.loadPage('results.html');
What I have done with the new one
// Init App
var priceApp = new Framework7({
root: '#app',
theme: theme,
template7Pages: true,
template7Data: {
'/results/': {
promo: '',
retail: '',
save: '',
imagelink: ''
}
},
});
var mainView = priceApp.views.create('.view-main')
//set the result data for result page to view
Template7.data = {
'/results/: {
promo: price,
retail: retail,
save: discount,
imagelink: prodimage
}
}
//Hide the loader
priceApp.preloader.hide()
priceApp.router.navigate('/results/')
and the routes:
var routes = [
// Index page
{
path: '/',
url: './index.html',
},
// Results page
{
path: '/results/',
templateUrl: './results.html',
},
];
If i am seeing this correctly this is no longer possible?
template7Data and such logic has been removed from v2. You can use app's root data for that:
var priceApp = new Framework7({
// ...
// data must be function that returns data object
data: function() {
// Return root data object
return {
results: {
promo: '',
retail: '',
save: '',
imageLink: '',
},
};
}
});
Later to access this data use priceApp.data and to add something:
priceApp.data.results = {
promo: price,
retail: retail,
save: discount,
imagelink: prodimage
}
To access root data in page rendered with Template7 (template7 page or component page) use $root:
<h1>Your price is {{$root.results.promo}}</h1>
...
Thank you very very much, just tried to send through a thank you via your paypal donate but it says payments aren't available at the moment. let me know or pm me on [email protected] and I'll get it through to you :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.