Facet methods

init()init()

This method allows to initialize facets script. It’s mainly used if you destroy() the instance. Otherwise, there isn’t any reason to init() facets since it’s automatically done by the plugin on load.

JS
Grid settings – JS field
wpgb.facets.init();

destroy()destroy()

You can destroy facets instance at any time thanks to this method.

JS
Grid settings – JS field
wpgb.facets.destroy();

refresh()refresh()

This methods allows to refresh facets and grid content. It can be useful if you programmatically change facets parameters thanks to setParams() or deleteParams() methods.

JS
Grid settings – JS field
wpgb.facets.refresh();

abort()abort()

This methods allows to abort an asynchronous task like refresh() method. It prevents making several requests at the same time which can lead to wrong results.

JS
Grid settings – JS field
wpgb.facets.abort();

pushState()pushState()

This methods allows to modify browser history and url. It is generally used after modifying facets parameters thanks to setParams() or deleteParams() methods and before to refresh() content.

JS
Grid settings – JS field
wpgb.facets.pushState();

reset()reset()

This methods allows to modify browser history and url. It is generally used after modifying facets parameters thanks to setParams() or deleteParams() methods and before to refresh() content.

ArgumentTypeDescription
facetsnull|arrayHold facet slug(s) to reset
JS
Grid settings – JS field
// Reset all facets.
wpgb.facets.reset();
// Reset specific facets.
wpgb.facets.reset( ['facet_slug_1', 'facet_slug_2'] );

getFacet()getFacet()

This methods allows to get facet(s) properties.

ArgumentTypeDescription
facetinteger|stringFacet id or slug
JS
Grid settings – JS field
// Get specific facet by its id.
wpgb.facets.getFacet( 1 );
// Get specific facet by its slug.
wpgb.facets.getFacet( 'facet_slug' );

hasFacet()hasFacet()

This methods allows to check if a facet exists.

ArgumentTypeDescription
facetinteger|stringFacet id or slug
JS
Grid settings – JS field
// Check if facet exists by its id.
wpgb.facets.hasFacet( 1 );
// Check if facet exists by its slug.
wpgb.facets.hasFacet( 'facet_slug' );

getParams()getParams()

This methods allows to get parameters (selected values) of a facet.

ArgumentTypeDescription
facetstringFacet slug
JS
Grid settings – JS field
wpgb.facets.getParams( 'facet_slug' );

hasParams()hasParams()

This methods allows to check if a facet has parameters (selected values).

ArgumentTypeDescription
facetstringFacet slug
JS
Grid settings – JS field
wpgb.facets.hasParams( 'facet_slug' );

setParams()setParams()

This methods allows to assign parameters (selected values) to a facet.

ArgumentTypeDescription
facetstringFacet slug
paramsarrayHolds facet parameters as string
JS
Grid settings – JS field
wpgb.facets.setParams( 'facet_slug', ['param1', 'param2'] );

deleteParams()deleteParams()

This methods allows to delete parameters (selected values) from a facet.

ArgumentTypeDescription
facetstringFacet slug
paramsarrayHolds facet parameters as string
JS
Grid settings – JS field
wpgb.facets.deleteParams( 'facet_slug', ['param1'] );