Heres the scenario.
I'm using mobile jQuery. Meaning my HTML gets updated using ajax.
I have a navigation menu on top.
I have 2 pages (ID= "#P1" and ID="#P10"). Both pages contain the same nav menu.
When user clicks on a icon on the menu it should slide one of my divs into the screen. When the user click "x" or outside of the new div it should get closed.
I'm handling this using the next JS code.
$(document).bind('pageinit', function() {
alert('TEST');
$(document).on('click' , '.menu_open' , function() {
$('.mask').addClass('mask_visible');
$('#menu').animate({
marginLeft: "0%",
opacity: 1
}, 200);
$('#menu').css('display', 'block');
});
$(document).on('click','.menu_close , .mask ', function() {
$('.mask').removeClass('mask_visible');
$('#menu').animate({
marginLeft: "-100%",
opacity: 0
}, 200);
});
$(document).on("swipeleft", '#menu', function(){
$('.mask').removeClass('mask_visible');
$('#menu').animate({
marginLeft: "-100%",
opacity: 0
}, 200);
});
});
Currently this code is placed in after all the scripts.
The problem is that my code works only on the first page that I load. After I redirect to the second page my "alert" code will trigger but I won't be able to pull out my nav bar anymore.