I am having some problem on JQuery Mobile, I am very new to this, so maybe my question might seem a bit naive.
I have 2 pages, 1 is the index.html
then I have a search.html
, I have a sidemenu plugin for both html. And I did autofocus for the search.html
. And when I click a button to go from index to search. My sidemenu isn't put into format and also the autofocus doesn't work. Only when I refresh the page it works. I have included all the css, js in every html. And I also already loaded all the script at the start of the page. And if I refresh on the search page and hit back to go back to the index, then the index page is messed up, and I have to refresh that to make it work as well.
Not sure why is that happening.
This is the search.html
<!DOCTYPE html>
<body>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile-1.4.4.min.css" />
<link rel="stylesheet" href="css/account.css" />
<link rel="stylesheet" href="css/jquery.mmenu.css" />
<link rel="stylesheet" href="css/jquery.mmenu.all.css" />
<script src="js/jquery-1.11.1.js"></script>
<script src="js/jquery.mobile-1.4.4.min.js"></script>
<script src="js/jquery.mmenu.min.all.js"></script>
<link rel="stylesheet" href="css/jquery.mmenu.fullscreen.css" />
<link rel="stylesheet" href="css/jquery.mmenu.positioning.css" />
<link rel="stylesheet" href="css/jquery.mmenu.themes.css" />
<script type="text/javascript">
$(document).on('pageinit',function() {
$("#menu").mmenu({
// options
}, {
// configuration
offCanvas: {
pageNodetype: "section"
}
});
});
</script>
<script>
$(document).on('pageshow', function(){
$("#searchinput").focus();
});
</script>
<script type="text/javascript">
$(document).on('pageinit', function() {
$("#menu").mmenu({
classes: "mm-light"
});
});
</script>
<script>
$("#menu").mmenu({
searchfield: false,
counters: true
});
$("#my-button").click(function() {
$("#menu").trigger("open");
});
</script>
<script type="text/javascript">
$.fn.mmenu.debug = function( msg ) {
console.log( msg );
};
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<div data-role="page" id="home">
<div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme="">
<a href="index.html" data-transition="none">Back</a>
<input type="search" id="searchinput" name="search-mini" value="" data-mini="true" placeholder="Where?"/>
</div>
<div>
<nav id="menu">
<ul>
<li id="infinitytest.html">Home<br><a>Test</a></li>
<li>My account</li>
<li>Setting</li>
</ul>
</nav>
</div>
<div>
<div role="main" class="ui-content scroll">
<ul data-role="listview" id="list"></ul>
</div>
</div>
</div>
</body>
</html>