Loading ...
Sorry, an error occurred while loading the content.

Updating multiple history items in one fell swoop

Expand Messages
  • pl0dal0ng
    Hi all, I m getting into the History Manager to completely Ajaxify part of a site. I m having a problem setting it up the way I want and hope you can help.
    Message 1 of 4 , Jul 3, 2007
    • 0 Attachment
      Hi all, I'm getting into the History Manager to completely "Ajaxify"
      part of a site. I'm having a problem setting it up the way I want and
      hope you can help. I want to update two things based on one click,
      one based on an attribute of the clicked element, and the other based
      on the innerHTML. I set up my click event to fire two navigate events:
      function() {
      YAHOO.util.History.navigate('img', this.attributes['myattr'].nodeValue);
      YAHOO.util.History.navigate('imgName', this.innerHTML);
      }
      This behaves unexpectedly. It puts two entries into history, for one
      thing, but the function registered to "img" doesn't fire. It does,
      however, if I hit the back button once. The URL appears to update as
      such:
      default states are "img5.jpg" and "five"
      click:
      url1: #img=img1.jpg&imgName=five
      url2: #img=img5.jpg&imgName=one

      Again, I don't "see" the state stored in url1, because clicking puts
      both in the history and only the second is executed. However,
      clicking back causes the "correct" state for the fragment in url1 to
      be applied.

      I have ideas and questions as to their feasibility:
      1) how can I update multiple history items at once?
      2) how do I pass the clicked object to my updateStuff function as
      this? The cheat-sheet suggests:

      YAHOO.util.History.register(str module, str initial state, fn
      callback[, obj associated object, b scope])

      and I have tried:

      YAHOO.util.History.register("img", initialImgState, function(state) {
      updateStuff(state) } );

      and

      YAHOO.util.History.register("img", initialImgState, function(state) {
      updateStuff(state)}, true );

      but all firebug gives me back is [object Window]

      Help is appreciated, thanks for reading!
    • pl0dal0ng
      Due to lack of interest in my earlier post and my ongoing attempts at a solution, I ve posted my test files for your clicking pleasure. The tests aren t
      Message 2 of 4 , Jul 5, 2007
      • 0 Attachment
        Due to lack of interest in my earlier post and my ongoing attempts at
        a solution, I've posted my test files for your clicking pleasure. The
        tests aren't directly related to the actual project, but it is
        analogous to what I'm trying to do.

        http://runion.cc/test/multiTest.html, I'm trying to update two
        parameters in the fragment simultaneously. I understand that this
        method shouldn't solve that need directly, but it does produce
        unexpected results. I get the same result if I register only one
        function to the click event and put both navigate commands into that
        function.

        As a second example, http://runion.cc/test/delayTest.html, I put a
        delay on the second navigate calls. THIS WORKS. It seems to be
        affected by a race condition, as setting to 10ms causes unreliable
        results on my computer (where the first function which updates the
        image isn't run).

        I could use these delays to update multiple items but I want to be
        able to step back throughout the program one "click" at a time, so to
        speak, rather than once for each call to YAHOO.util.History.navigate.
      • pl0dal0ng
        Fixed URLs for posterity: http://runion.cc/test/multiTest.html http://runion.cc/test/delayTest.html
        Message 3 of 4 , Jul 5, 2007
        • 0 Attachment
        • Julien Lecomte
          Hi, Sorry for not getting back to you sooner. These two features will be available in the upcoming version of YUI, available in just a few weeks. So, stay
          Message 4 of 4 , Jul 5, 2007
          • 0 Attachment
            Hi,

            Sorry for not getting back to you sooner. These two features will be
            available in the upcoming version of YUI, available in just a few weeks.
            So, stay tuned!

            Regards,
            Julien


            On Tue, 2007-07-03 at 19:05 +0000, pl0dal0ng wrote:
            > Hi all, I'm getting into the History Manager to completely "Ajaxify"
            > part of a site. I'm having a problem setting it up the way I want and
            > hope you can help. I want to update two things based on one click,
            > one based on an attribute of the clicked element, and the other based
            > on the innerHTML. I set up my click event to fire two navigate events:
            > function() {
            > YAHOO.util.History.navigate('img',
            > this.attributes['myattr'].nodeValue);
            > YAHOO.util.History.navigate('imgName', this.innerHTML);
            > }
            > This behaves unexpectedly. It puts two entries into history, for one
            > thing, but the function registered to "img" doesn't fire. It does,
            > however, if I hit the back button once. The URL appears to update as
            > such:
            > default states are "img5.jpg" and "five"
            > click:
            > url1: #img=img1.jpg&imgName=five
            > url2: #img=img5.jpg&imgName=one
            >
            > Again, I don't "see" the state stored in url1, because clicking puts
            > both in the history and only the second is executed. However,
            > clicking back causes the "correct" state for the fragment in url1 to
            > be applied.
            >
            > I have ideas and questions as to their feasibility:
            > 1) how can I update multiple history items at once?
            > 2) how do I pass the clicked object to my updateStuff function as
            > this? The cheat-sheet suggests:
            >
            > YAHOO.util.History.register(str module, str initial state, fn
            > callback[, obj associated object, b scope])
            >
            > and I have tried:
            >
            > YAHOO.util.History.register("img", initialImgState, function(state) {
            > updateStuff(state) } );
            >
            > and
            >
            > YAHOO.util.History.register("img", initialImgState, function(state) {
            > updateStuff(state)}, true );
            >
            > but all firebug gives me back is [object Window]
            >
            > Help is appreciated, thanks for reading!
            >
            >
            >
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.