Ajax data on index

Hello all,

I have figured out how to populate templates with data retrieved from an Rest API. This works pretty well. What I don’t know is how to do this on the index (home) of the app.

This what I’ve set up on ‘/items/’ (and works), and this is basically what I would wan’t to do on the index as well: https://gist.github.com/jeffreyvr/fdbd207ba3d9eaf54d7f00fa9d0fc423

Does anyone know how to best do this? Any help is of course appreciated!

Check the “Initial Page” section at https://blog.framework7.io/mastering-v2-router-958ea2dbd24f. You may do the same for home page just need to keep view empty on app load

1 Like

There maybe a better way to do this, but you could try making your items page your home page. Load it on pageInit or whenever you want to refresh the data, it’s pretty smooth:

  1. Set options in your router.js to

      options: {
           animate: false,
           reloadCurrent: true,
         },
    
  2. Then call load when ever you want to refresh your data.

          methods: {
               load: function() {
                app.router.navigate(/items/);
              }
         }
1 Like