I did a search div that appears and disappears at the click of a button .
Thanks to this input jquery search automatically filters the contents of a div .
The problem arises when you press the enter key . The page reloads and the button to bring up the div search no longer works .
When I switch from one page to another the script is not always loaded .
But if I update the page , the script continues to work well.
How can i solve?? Thanks
paste the code :
- <!DOCTYPE html>
<html>
<head>
<meta name = "robots" content = "noindex" >
<meta name = "googlebot" content = "noindex" >
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
<meta name = "viewport" content = "width=device-width, initial-scale=1" />
<link rel = "stylesheet" href = "css/jqm_1.4.2/jquery.mobile.theme-1.4.2.min.css" />
<link rel = "stylesheet" href = "css/jqm_1.4.2/jquery.mobile.icons-1.4.2.min.css" />
<link rel = "stylesheet" href = "css/jquery.mobile.structure-1.4.2.min.css" />
<link rel = "stylesheet" href = "css/mobijq.css" />
<script src = "js/jquery-1.9.1.min.js" ></script>
<script src = "js/jquery.mobile-1.4.2.min.js" ></script>
<script src = "js/jquery.mobijq.min.js" ></script>
<script type = "text/javascript" >
$ ( document ). ready ( function () {
var clicked = true ;
$ ( "#ricerca" ). on ( 'click' , function (){
if ( clicked )
{
clicked = false ;
//
$ ( "#ricerca_box" ). css ({ "display" : "block" });
$ ( "#search_clienti" ). focus ();
}
else
{
clicked = true ;
$ ( "#ricerca_box" ). css ({ "display" : "none" });
}
});
});
</script>
</head>
<body>
<div data-role="page" id="page1" data-title=" <? php echo $sito_internet . ' vers. ' . $vers ?> " data-theme="c" style="background-repeat:repeat repeat;">
<div data-role = "header" data-theme = "a" data-fullscreen = "false" data-position = "false" data-tap-toggle = "true" data-track-persistent-toolbars = "true" >
<a id = "ricerca" class = "ui-btn-right" href = "" > Cerca </a>
</div>
<div role = "main" class = "ui-content" >
<div id = "main" >
<div id = "ricerca_box" class = "ui-body ui-body-e " style = " width : 99 %; margin : auto ; padding : 0px ;; background - repeat : repeat repeat ; " >
<form><input type = "text" data-type = "search" id = "search_clienti" /></form>
</div>
<h2 style = " text - align : center ; " > Lista </h2>
<ul data-role = "listview" data-input = "#search_clienti" data-filter = "true" >
<li><table><tr><td width = "400" > Acura </td><td> 080394 </td><td> bari </td></tr></table></li>
<li><table><tr><td width = "400" > ciccio </td><td> 080347 </td><td> giovinazzo </td></tr></table></li>
<li><table><tr><td width = "400" > cappuccio </td><td> 088343432 </td><td> ruvo </td></tr></table></li>
<li><table><tr><td width = "400" > pinco </td><td> 0623423 </td><td> giovinazzo </td></tr></table></li>
<li><table><tr><td width = "400" > pallino </td><td> 02766565454 </td><td> giovinazzo </td></tr></table></li>
<li><table><tr><td width = "400" > ignazio </td><td> 0803933332 </td><td> bari </td></tr></table></li>
<li><table><tr><td width = "400" > rento </td><td> 08034234234 </td><td> molfetta </td></tr></table></li>
<li><table><tr><td width = "400" > ciccillo </td><td> 24324324232</td><td> bari </td></tr></table></li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>