How to use Template7 with ajax data on index.html?


#1

The following doesn’t work for me. I’d like to load ajax data on my homepage. It was very easy to do this with preprocess in v1.

var app = new Framework7({
  root: '#app',
  routes: [
    {
      path: '/',
      async: function(routeTo, routeFrom, resolve, reject) {
       app.request.postJSON('my-url', function (data) {
         resolve(
          {
            context: {
              photos: data
            }
          },
          {
            templateUrl: './index.html'
          }
        );
       });
      }
    }
  ]
});

var mainView = app.views.create('.view-main', {
  url: '/'
});

#2

Move home page template to different file from index.html


#3

So you can’t place it in the same page anymore, like you were able to in F7 v1? I used to be able to just do preprocess on all the pages and simply do mainView.router.refresh() on page load for it work on index.html. Can you achieve this without needing to do that in F7 v2?