I am working on a Cordova project using Onsen. I have multiple ons-pages and if I change from one to another and back to the first one, the whole code is executed twice. If I do it again, everything happens three times, four times and so on.
Like I load a view with:
$(document).on('click','#next',function() {
fn.load("views/test.html");
});
View looks like:
<ons-page id="test">
<img class="back_icon" id="picture" src="pictures/graphic.png" alt="back"/>
<script>
console.log(1);
$(document).on('click','#picture',function() {
fn.load("views/back.html");
});
</script>
</ons-page>
I go to this page first time, console: 1 I go back to another view and use it again, console: 1, 1, 1 Again: 1, 1, 1, 1, 1, 1, 1, 1
And it does this with everything, but I have no clue why it does this. (It appears in Firefox, Chrome and on Android)
Has somebody had an idea for me? Seems like I am missing a basic point of switching between views...
Thank you!