Enter the url hash. Provided you're not using the Router, appending the #hash to the url is a viable and easy option. It's easy to add and tie into the TabStrip, obeys back button, and typically makes semantic sense.
It's possible to jump in on the TabStrip's activate event and add the tab's id to the URL, but that requires doing so for every single TabStrip where this behavior is desired. Sounds like a lot of boilerplate. I want it globally default.
So then next option is to monkey patch it. The basic action is that we replace the TabStrip plugin with a wrapper. The wrapper automatically adds an 'activate' listener to set the window hash. It will also check if there's a window hash on page load and set that as active.
So we add this in along with, but after, the basic kendoui includes. Any tab strip in the site will now automatically set itself up to preserve state - autowiring the activate event and on load.
We can customize the hash slug by adding in data-slug attributes to the tab strip headers like so:
<div id="Tabs"> <ul> <li data-navigation="foo">Bar</li> </ul> ... </div>
Note, have only really tested with ASP.Net MVC extensions.
No comments:
Post a Comment