1

How can I refresh a div in jqm? My problem is I have a div(#menu) on a toggle to show/hide. This works fine but when I navigate through pages the toggle script gets disabled. I have to refresh the page it's on or disable ajax for all pages.

I have read through posts with similar issues and tried the solutions like listview('refresh') but nothing seems to work.

Here is my code. Many thanks.

<div data-role="page" id="page1">

<div data-role="header">
<h1>Page 1</h1>
</div>

<div data-role="content">

<!-- TOGGLE --> 
<div data-role="navbar" data-grid="a" id="menu">
<ul>
<li><a href="#">News</a></li>
<li><a href="#">Items</a></li>
</ul>
</div>
<!-- /TOGGLE --> 

<a href="#" data-role="button" id="nav">open menu</a>

</div>

<div data-role="footer">
footer content
</div>

<script>
$('#nav').click(function() {
$('#menu').toggle(); 
});
</script>

</div>
4

1 に答える 1

0

classesの代わりに使用してidsください:

$('.nav').click(function() {
  $('.menu').toggle(); 
});

最後のhttp://jsfiddle.net/ouadie/CuGkW/1/の<script>..</script> に入れます</div>

于 2013-04-25T12:59:54.190 に答える