Disable history feature
data-enable-history=“false"
Manually update the state in the URL hash
var search = $('#search');
search.on('state:change', function() {
var attributes = search.coveo(Coveo.QueryStateModel).getAttributes();
var queryString = encodeURIComponent(Coveo.HashUtils.encodeValues(attributes));
// Update the hash
router.navigate('search?' + queryString); // window.location.hash = 'search?' + queryString
});
Manually parse the hash
var MyRouter = Backbone.Router.extend({
routes: {
"search/?:query": "search"
},
search: function(query) {
var newState = this.parseState(query);
var search = $('#search');
var currentState = search.coveo('state');
search.coveo('state', _.defaults(newState, currentState.defaultAttributes));
search.coveo('executeQuery'); // Not sure if needed everytime
}
parseState: function() {
var state = URI.parseQuery(decodeURIComponent(hash));
var parsedState = {};
_.each(state, (value, key) => {
parsedState[key] = Coveo.HashUtils.getValue(key, '#' + decodeURIComponent(hash));
});
return parsedState;
}
});
Should be similar with react-router
or angular