[SOLVED] [Dom7] - Handle non-index pages events

Hello,

I’m new to Framework 7 and I find it a little more complicated than I firstly expected.

I have downloaded the “kitchen-sink” example to understand it a little more and I have started by modifying this example app.

As I can see, there’s an app.js script wich intializes the Framework and provides you all the functionality. I tried to handle some events here like I’d do with jQuery and it works prefectly, but the problem comes when I try to handle events in another html than index.html. It does not do anything. I tried to handle them in app.js and in tags, but nothing happens.

Resume: I have another html, specified in routes.js, wich contains a smart select. I want to handle the ‘change’ event as I do in jQuery, but it seems impossible.

You need to write the code in appropriate place. The most recommended way is to use Router Components where you can put all component related logic into single file. Other way is to use page events:

$(document).on('page:init', 'page[data-name="some-page"]', function (e) {
  // do something here for page with data-name="some-page" attribute
});

Hi. Sorry for the late answer and thank you for your help.

Effectively, I used the second way and it handles the events perfectly. I wrote it in separate scripts.

Greetings.