Hi,

I'm using json to update a list and it works fine, but the goodies
(back button, bookmarks...) are obviously not working.

My goal is to keep a version that generates the html lists (for the
ones without js enabled), keep the json update features, and add the
history working.

I'm struggling to make the history plugin. I suspect that's it's a mix
of various problems, but I'd like to check with you if this plugin can
make what I want or if I'm digging the wrong hole.

Main problems
1) the $.ajaxHistory.initialize don't call the extra function to init
without hash
2) the remote() function, as far as I understand, seems to want to
call the same href than the "normal" link but as an ajax call that
returns html that it displays directly in a div

Let me describe it a wee bit more in detail:

So far on the server , what I have is a url that works without any js
and display the list in regular html
url : list?parent=nnn generates

<ul id="list">
<li><a href="list?parent=123" id="link_123" class="remote">See what's
below 123</a>
<li><a href="list?parent=42" id="link_42" class="remote">See what's
below 42</a>

and a json
url: /json/list?id=link_nnn

that produces a JSON list of these items

The js basically replaces the html links by json calls (initJSON) +a
javascript function that generates the html from the json list
(updateList):


      function initJSON () {
// replace the regular link by a json call
          var basejson="/json/list?id=";
         jQuery(" a.remote").removeClass("remote").click(function (){
             $.getJSON(basejson+this.id, {  }, updateList);
             return false;
           });
// I would like to replace that by a call that keeps the history eg ?
// (problem 2) )
//        $('a.remote').remote(???);

}
function updateList (items) {
  var html="";
  // loop on items, some templating so html contain something...
  $('#list').append(html);
  initJSON();
}

jQuery(function(){
// I want to initialise the list if no param has been set (no ?
parent=xxx)
// (problem 1) )
//  $.ajaxHistory.initialize(function (){alert("should initialise the
list one way or another");});

  initJSON();

}


Any idea ? I didn't find losts of examples of this plugin beside the
tab, do you think that's the right tool to use ?

X+

Reply via email to