Problems with navigation and json request

Problems with navigation and json request

Hello,

i have problems with navigation on my html site.

I use the bb-bqq.js and jquery.

Code Example:

In one external javasrcipt file i started the standard json request and use the .push function for the result.

the main file called the javascript by clicking button.

The result will be pushed in a div and will be show - thats noch problem. i have problem to get back before i started the request by the button.

I think the soultion should be easy, because it's a standard way in using mobile sites.

I hope someone has the idea or a solution.

Thanks.

main site:

  1. <head>
  2. ....
  3. <script type="text/javascript" language="JavaScript" src="lib/js/jquery.ba-bbq.js"> </script>
  4. <script type="text/javascript" language="JavaScript" src="lib/js/nav.js"> </script>
  5. ....
  6. </head>


      [....]
  1. <div class="page-main" id="main" href="main">
  2.  <div id="test1">   <a href="#test1">test 1</a> </div>
  3.   <div id="test2">   <a href="#test2" id="products">test 2</a> </div>
  4.   <div id="test3">   <a href="#test3">test 3</a> </div>
  5.   <div id="test4">   <a href="#test4">test 4</a> </div>
  6. </div>

[....]

external js:

  1. $(document).ready(function (){

  2. $("#products").click(function(event){
  3. $.getJSON("lib/products", function(data){
  4.             var html = [];

  5.       $.each(data, function(index, pr){

  6.       html.push( pr.name + ' '+ pr.nr)

  7.       });

  8.      $("#test2").html(html.join(''));

  9.          });

  10.       });


  11.            }).
  12.            error(function(jqXHR, textStatus, errorThrown){ /* assign handler */
  13.           /* alert(jqXHR.responseText) */
  14.           alert("error occurred!");
  15.       });

nav.js

  1. $(document).ready(function (){
  2. $(function(){

  3.   // Bind an event to window.onhashchange that, when the hash changes, gets the
  4.   // hash and adds the class "selected" to any matching nav link.
  5.   $(window).hashchange( function(){
  6.     var hash = location.hash;

  7.     // Set the page title based on the hash.
  8.     document.title = 'The hash is ' + ( hash.replace( /^#/, '' ) || 'blank' ) + '.';

  9.     // Iterate over all nav links, setting the "selected" class as-appropriate.
  10.     $('#main button').each(function(){
  11.       var that = $(this);
  12.       that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'selected' );
  13.     });
  14.   })

  15.   // Since the event is only triggered when the hash changes, we need to trigger
  16.   // the event now, to handle the hash the page may have loaded with.
  17.   $(window).hashchange();

  18. });
  19. });


i get the result in the test2 div, but it'snt possible to get back.