Event is repeating even on clicking once?

My app.js contains following code:-

        var liketype="b";
        var likeid=$$(this).attr("value");
        var num_of_likes=$$(this).attr("likesd");
        var liked=$$(this).attr("liked");

Above code works fine if the page is visited once.If the page is visited twice, the event will be fired twice even on clicking once as page is initialised twice. How to avoid this problem? I cannot place the event outside init event as it requires id which is only available inside the page.

Because you use events in a wrong way

change to


I tried your solution but problem persists. When i changed my code to following:-

  console.log('page is getting intialised');

When i’m visiting the page second time, it’s getting initialised twice and when i visited it 3rd time, it’s getting initialised three times as shown in console.

what framework ??

  1. Cordova
  2. Ioninc
  3. React
  4. Phonegap

Cordova but i believe that this problem is platform independent

I believe there are two ways of solving the problem
1)Remove all the events attached to the page before it gets destroyed
2) Implement some sort of timer like mechanism which will ensure that page is initialised only once.
But i don’t know how to implement them in framework7. Any idea @nolimits4web

Page initialized only once in F7. You error still means you added that event listener somewhere in wrong place, but such “LIVE” event listener like you have:


More likely should be placed only once in main file, not in any event handler.



All the page initialisation events are placed in app.js and events are placed in the init event. what i don’t understand is why console has been logging the event multiple times but not when visited first time.


var liketype=“b”;
var likeid=$$(this).attr(“value”);
var num_of_likes=$$(this).attr(“likesd”);
var liked=$$(this).attr(“liked”);