The following code works but i would like to replace the lines $("#homepage").hide(); with $("#page").hide(); so i can take care of multiple pages. the problem is that the page will hide the page div but not show the homepage div again but it will show and hide the divs correctly if there are no parent divs involved.
<html>
<body>
<div id="page">
<div id="homepage">
<h1>home</h1>
</div>
<div id="advert">
<h1>advert</h1>
</div>
</div>
<script>
var app = $.sammy(function() {
this.get('#/', function() {
$("#ad").hide();
$("#homepage").show();
});
this.get('#ad/', function() {
$("#homepage").hide();
$("#ad").show();
});
});
app.run();
</script>
</body>
</html>
i modify the code as follows to demonstrate my intended usage:
var app = $.sammy(function() {
this.get('#/', function() {
$("#page").hide();
$("#homepage").show();
});
this.get('#ad/', function() {
$("#page").hide();
$("#ad").show();
});
});
app.run();
this code produces a window that is blank and does not show the homepage or ad page. i have tried with multiple different routing libraries.
I didn't used sammy.js library. I found simple sample example. check below link.
https://jsfiddle.net/KZknm/34/
here is Html