How to use page init?

hello,code like this,dont work,why?

Место где app.on - если у вас Cordova, то события с большой вероятностью вы не поймаете, т.е. init будет после device ready.

hi,can you reply english?

try assign url prop to .main-view
<div class="view view-main" url="/"></div>
and also make sure u install routes as well

thanks, but the same

you have to declare routes at init app
> var app = new Framework7({

  // App root element
  root: '#app',
  // App Name
  name: 'My App',
  // App id
  id: 'com.myapp.test',
  // Enable swipe panel
  panel: {
    swipe: 'left',
  // you have to declare routes at init app
> routes: [
      path: '/about/',
      url: 'about.html',
  // ... other parameters

Here on forum, there are lot of similar topics. It happens because you add your page:init handlers AFTER home page was initialized. Add them before new Framework7 or add it to app parameters events, on: {pageInit() {....}}

1 Like

thanks very much! it is work

Не “url”, а data-url.

И так нельзя писать. Или добавить view-init или убрать data-url="/", а добавить url при создании view с помощью JS.
Здесь " In this case we may pass them in data- attributes.

I need to use an app.request at home page load, so if I put it before new Framework7 or on: {pageInit() {....}} it will not work

I tried:

$(document).on('page:beforein', '.page[data-name="home"]', function (e) {

But it only works when I navigate to another pages and back to home. page:init doesn’t work too

How can I use a request every time home page loads, including at the first load?