Class jQuery.sap.historyModule: jquery.sap.history
Enables the back and forward buttons in browser to navigate back or forth through the browser history stack.
It also supports adding virtual history which used only to mark some intermediate state in order to navigate back to the previous state. And this state will be skipped from the browser history stack immediately after a new history state is added to the history stack after this state
By providing the hash saved from the return value of calling jQuery.sap.history.addHistory, jQuery.sap.history.backToHash will navigate back directly to the history state with the same hash.
Please use jQuery.sap.history.back() to go one step back in the history stack instead of using window.history.back(), because it handles the empty history stack situation and will call the defaultHandler for this case.
Example for the usage of history handling:
//Initialization jQuery.sap.history({ routes: [], //please refer to the jQuery.sap.history function comment for the format. defaultHandler: function(){ //code here } }); //add history var hash = jQuery.sap.history.addHistory("IDENTIFIER", jsonData); //add virtual history jQuery.sap.history.addVirtualHistory(); //back to hash jQuery.sap.history.backToHash(hash); //back one step along the history stack jQuery.sap.history.back();
Deprecated API:since 1.19.1. Please use sap.ui.core.routing.Route instead.
Initialize the history handling and set the routes and default handler. This should be only called once with the mSettings set in the right format. If the mSettings is not an object, you have another chance to call this function again to initialize the history handling. But once the mSettings is set with an object, you can only call the addRoute and setDefaultHandler to set the data.
{object} | mSettings | The map that contains data in format: { routes: [{ path: string //identifier for one kind of hash handler: function //function what will be called when the changed hash is matched against the path. //first parameter: the json data passed in when calling the addHistory //second parameter: the type of the navigation jQuery.sap.history.NavType }], defaultHandler: function //this function will be called when empty hash is matched //first parameter: the type of the navigation jQuery.sap.history.NavType } |
- Deprecated:
- since 1.19.1. Please use sap.ui.core.routing.Route instead.
{string} | sIdf | The identifier defined in the routes which will be matched in order to call the corresponding handler |
{object} | oStateData | The object passed to the corresponding handler when the identifier is matched with the url hash |
{boolean} | bBookmarkable | Default value is set to true. If this is set to false, the default handler will be called when this identifier and data are matched |
{boolean} | bVirtual? | This states if the history is a virtual history that should be skipped when going forward or backward in the history stack. |
{string} | sHash The complete hash string which contains the identifier, stringified data, optional uid, and bookmarkable digit. This hash can be passed into the backToHash function when navigating back to this state is intended. |
{string} | sIdf | The identifier that is matched with the hash in the url in order to call the corresponding handler. |
{function} | fn | The function that will be called when the identifier is matched with the hash. |
{object} | oThis? | If oThis is provided, the fn function's this keyword will be bound to this object. |
{object} | It returns the this object to enable chaining. |
{int} | iSteps? | how many steps you want to go back, by default the value is 1. |
{string} | sPath | The route identifier to which the history navigates back. |