lz.HistoryService
Manages interaction with the browser history and back button.

JavaScript: lz.HistoryService
extends lz.Eventable »

lz.History is the single instance of the class lz.HistoryService.

The lz.History service manages interaction with the browser history and back button. Save state as often as you like, and advance the history when a new 'page' of values is required.

 <form>
     <input type="button" value="0" onclick="lz.embed.setCanvasAttribute('foo', 0)"/> 
     <input type="button" value="1" onclick="lz.embed.setCanvasAttribute('foo', 1)"/> 
 </form>
 

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
offset   Number   readonly
  The current offset (zero-based) in the history value stack. Listen for the onoffset event to find out when lz.History value changes.
persist   Boolean   readonly
  If true, persistence is on.
_persistso   Object   readonly
  If set, use this persisted object.
ready       read/write
  true if history system is ready to receive events

Class Attributes

Name (CSS property) Type (tag) Type (js) Default Category
LzHistory   lz.HistoryService   readonly
  The history service. Also available as the global lz.History.

Methods

clear()
lz.HistoryService.clear();
Clears out the history state.

next()
lz.HistoryService.next();
Moves forward one step in the history stack. Adds an item to the browser history.

prev()
lz.HistoryService.prev();
Moves back one step in the history stack. Adds an item to the browser history

save()
lz.HistoryService.save(who : String, prop : String, val : *);
Saves a value and attribute name callback in the current offset of the history stack. When the browser back button causes the history offset to change, the attribute will get set to the value saved at that offset, e.g. scope.setAttribute('attribute_name_to_set', value).
Parameter Name Type Description
who String Global id of the scope to be used
prop String Attribute name to be set
val * Value to set the attribute to

setPersist()
lz.HistoryService.setPersist(p : Boolean);
Turns history persistence across app reloads on or off
Parameter Name Type Description
p Boolean If true, persistence will be turned on

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onoffset Sent when the history offset changes.
onready Sent when history events are ready to be sent and received.

Events inherited from lz.Eventable

ondestroy