Function from previous page is getting called?

$$(document).on('page:init','.page[data-name="page1"]',function(e,page){
   page.$el.on("click",'.commentbutton',function(){
       console.log("i'm at page1");
   });
});
$$(document).on('page:init','.page[data-name="page2"]',function(e,page){
   page.$el.on("click",'.commentbutton',function(){
       console.log("i'm at page2");
   });
});

When i navigate to page2, on clicking commentbutton, the function of previous page gets called even when current page has already a function defined for it and when i go back to page1 . function at page2 gets called

its working ok for me:

i use a previos fiddle, just enter the popup, in home and link2, you have the buttons. scroll down. open the console and click them .

jsfiddle

can you make a small fiddle with the error?

1 Like