3

I have feature whereby am constructing a url like :

http://localhost/listings?q=&idx=content_index&p=0&dFR[objectID][0]=97&dFR[objectID][1]=96

It creates a facetFilters: [["objectID:97","objectID:96"]]"}. I have a clear All feature also which clear all the filters:

        search.addWidget(
        instantsearch.widgets.clearAll({
            container: '#clearAll',
            templates: {
                link: '<i class="icon icon-undo2"></i>'
            },
            autoHideContainer: false,
            clearsQuery: true
        })
    );

This works perfectly fine and clears the above filter also. But the issue came when started routing. With routing,

http://localhost/listings?q=&idx=content_index&p=0&dFR%5Bgenres.name%5D%5B0%5D=Comedy

changed to :

http://localhost/listings?genres=Comedy

Have done the below changes for the above:

routing: {
stateMapping: {
    stateToRoute(uiState) {

        return {
            query: uiState.query,
            // we use the character ~ as it is one that is rarely present in data and renders well in urls
            genres:
            uiState.refinementList &&
            uiState.refinementList['genres.name'] &&
            uiState.refinementList['genres.name'].join('~'),
            page: uiState.page
        };
    },
    routeToState(routeState) {

        return {
            query: routeState.query,
            refinementList: {
                'genres.name': routeState.genres && routeState.genres.split('~'),
            },
            page: routeState.page
        };
    }
}

},

Have to implement the same functionality for objectID. How to do that?

Sonal
  • 425
  • 1
  • 5
  • 12

0 Answers0