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

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

Move home page template to different file from index.html

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?

hello,excuse me,have u solved it ? i think i met the same problem
could u please tell me about some ways? thanks!!:微笑:

excuse me,I don’t seem to catch your meaning :苦涩: