simplicityState

Recording the question.

The simplicityState widget wraps a JSON representation of state which is typially used for driving search.

In the common case each page contains just one simplicityState widget bound to the body element.

To create an empty state.

$('body').simplicityState();

To create a pre-populated state, you’d use the initialState option.

$('body').simplicityState({
  example: 'this is my default state'
});

To obtain the current state.

$('body').simplicityState('state');

To set the current state.

$('body').simplicityState('state', {
  example: 'this is my new state'
});

To get notified when the state changes. Note that the widget uses $.triggerHandler to prevent event bubbling.

$('body').bind('simplicityStateChange', function (state) {
  console.log('state changed to', state);
});