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:
- <head>
- ....
- <script type="text/javascript" language="JavaScript" src="lib/js/jquery.ba-bbq.js"> </script>
- <script type="text/javascript" language="JavaScript" src="lib/js/nav.js"> </script>
- ....
- </head>
[....]
- <div class="page-main" id="main" href="main">
- <div id="test1"> <a href="#test1">test 1</a> </div>
- <div id="test2"> <a href="#test2" id="products">test 2</a> </div>
- <div id="test3"> <a href="#test3">test 3</a> </div>
- <div id="test4"> <a href="#test4">test 4</a> </div>
- </div>
[....]
external js:
- $(document).ready(function (){
-
- $("#products").click(function(event){
- $.getJSON("lib/products", function(data){
- var html = [];
-
- $.each(data, function(index, pr){
-
- html.push( pr.name + ' '+ pr.nr)
-
- });
-
- $("#test2").html(html.join(''));
-
- });
-
- });
-
-
- }).
- error(function(jqXHR, textStatus, errorThrown){ /* assign handler */
- /* alert(jqXHR.responseText) */
- alert("error occurred!");
- });
nav.js
- $(document).ready(function (){
- $(function(){
-
- // Bind an event to window.onhashchange that, when the hash changes, gets the
- // hash and adds the class "selected" to any matching nav link.
- $(window).hashchange( function(){
- var hash = location.hash;
-
- // Set the page title based on the hash.
- document.title = 'The hash is ' + ( hash.replace( /^#/, '' ) || 'blank' ) + '.';
-
- // Iterate over all nav links, setting the "selected" class as-appropriate.
- $('#main button').each(function(){
- var that = $(this);
- that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'selected' );
- });
- })
-
- // Since the event is only triggered when the hash changes, we need to trigger
- // the event now, to handle the hash the page may have loaded with.
- $(window).hashchange();
-
- });
- });
i get the result in the test2 div, but it'snt possible to get back.