framework7

Open full view…

Quick change

Shaun Byrnes
Mon, 09 Feb 2015 04:19:42 GMT

Within the app.init() function, there is a section: $('.page:not(.cached)').each(function () { var pageContainer = $(this); var viewContainer = pageContainer.parents('.' + app.params.viewClass); if (viewContainer.length === 0) return; var view = viewContainer[0].f7View || false; var url = view && view.url ? view.url : false; if (viewContainer) { viewContainer.attr('data-page', pageContainer.attr('data-page') || undefined); } app.pageInitCallback(view, {pageContainer: this, url: url, position: 'center'}); }); Which initialises each of the pages which are present when the app starts. Is it possible to expose the callback function which is executed within each statement as a public method? Currently I have copied the code to use when initialising pages added dynamically, but I would rather call from Framework7 directly in case there are changes. This would help when I am adding popups to the <body> on the fly and have to compile them the angular way, then need to init them the Framework7 way (simply calling pageInit() is not suitable as that doesn't invoke callbacks/events - which I am listening for to perform other actions already). So something like (call the method whatever suits): app.defaultPageInit = function () { var pageContainer = $(this); var viewContainer = pageContainer.parents('.' + app.params.viewClass); if (viewContainer.length === 0) return; var view = viewContainer[0].f7View || false; var url = view && view.url ? view.url : false; if (viewContainer) { viewContainer.attr('data-page', pageContainer.attr('data-page') || undefined); } app.pageInitCallback(view, {pageContainer: this, url: url, position: 'center'}); }; ... $('.page:not(.cached)').each(app.defaultPageInit);

Vladimir Kharlampidi
Mon, 09 Feb 2015 16:03:52 GMT

Added this public method https://github.com/nolimits4web/Framework7/commit/417eb657caee08bf6cc6b6b565a24e4a111ee484

Shaun Byrnes
Mon, 09 Feb 2015 21:59:17 GMT

Thanks a lot for the quick turn around Vlad - I will give this a try and let you know!

Shaun Byrnes
Tue, 10 Feb 2015 04:04:42 GMT

Works well :)