promisefeni / reallysimplehistory

Automatically exported from code.google.com/p/reallysimplehistory
Other
0 stars 0 forks source link

Enhancement: update method #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I couldn't find a mailing list, so I thought of mentioning it here.

I added this method to window.dhtmlHistory :

{{{
  update: function(newLocation, historyData) {
         historyStorage.put(newLocation, historyData);
         if (this.isInternetExplorer())
            this.iframe.src = "blank.html?" + newLocation;
  }
}}}

update /  "update state" similar to add / "add state"

Motivation: my javascript-wizard has several input fields at each step, and
 the user might expect that the state is saved after changes to each of the
fields. At the same time after changing one field, the user would not
expect the back-button to undo that last change only.

So call this update method with newLocation chosen the same for each step
and historyData updated to reflect new state.

Any comments?

Thanks for the code!

Stephan

Original issue reported on code.google.com by stephanw...@gmail.com on 16 Oct 2007 at 4:25

GoogleCodeExporter commented 8 years ago
Stephan - interesting suggestions. Can you explain a little bit more what this 
does
that add() doesn't already do? If you call add() using a key (newLocation) that 
has
previously been stored, it will simply update the existing key with your new
historyData. You can see this at work in the new test page in the 0.6 beta. 
Please
let me know if I'm missing something here. At the very least I should work the
existence of this functionality into the release notes/comments/documentation.

Original comment by bdpathfi...@gmail.com on 24 Oct 2007 at 8:54

GoogleCodeExporter commented 8 years ago
Yes, I forgot to mention -- there is a flicker in the URL bar (sometimes) when 
using
add (not the suggested update) -- in my Firefox. I put together a patch against
RSH0.6PC.zip to demonstrate

Stephan

diff RSH0.6/rsh0.6.js RSH0.6update/rsh0.6.js
53a54,59
>         update: function(newLocation, historyData) {
>           historyStorage.put(newLocation, historyData);
>           // don't know what happened to this function - SW
>           // if (this.isInternetExplorer())
>           //  this.iframe.src = "blank.html?" + newLocation;
>         },
diff RSH0.6/rshTestPage.html RSH0.6update/rshTestPage.html
190a191
> var lastAddedLocation
196a198
>         lastAddedLocation = a[0]
202a205,216
>         
> }
> updateHistoryEvent_I = function() {
>         if(!lastAddedLocation) {
>           alert('No history data to update')
>           return
>         }
> 
>         testUpdateEntry = 'Add-Update at ' + new Date()
>       dhtmlHistory.add(lastAddedLocation,testUpdateEntry)
>       var msg = "A history event has been added: [newLocation=" +
lastAddedLocation + " | historyData=" + testUpdateEntry + "]";
>       log(msg, "logDH");
204a219,229
> updateHistoryEvent_II = function() {
>         if(!lastAddedLocation) {
>           alert('No history data to update')
>           return
>         }
> 
>         testUpdateEntry = 'Update-Update at ' + new Date()
>       dhtmlHistory.update(lastAddedLocation,testUpdateEntry)
>       var msg = "A history event has been added: [newLocation=" +
lastAddedLocation + " | historyData=" + testUpdateEntry + "]";
>       log(msg, "logDH");
> }
281a307,308
>       | <a href="javascript:updateHistoryEvent_I();">update history - with 
add</a>
>       | <a href="javascript:updateHistoryEvent_II();">update history - with 
update</a>

Original comment by stephanw...@gmail.com on 25 Oct 2007 at 5:01

GoogleCodeExporter commented 8 years ago

Original comment by bdpathfi...@gmail.com on 28 Oct 2007 at 6:02

GoogleCodeExporter commented 8 years ago

Original comment by bdpathfi...@gmail.com on 5 Nov 2007 at 6:34

GoogleCodeExporter commented 8 years ago

Original comment by bdpathfi...@gmail.com on 14 Nov 2007 at 12:58

GoogleCodeExporter commented 8 years ago
gggggggg

Original comment by kumar.sh...@gmail.com on 3 Jan 2012 at 5:14