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.
wpgb.facets.init();
destroy()destroy()
You can destroy facets instance at any time thanks to this method.
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.
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.
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.
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.
Argument | Type | Description |
facets | null|array | Hold facet slug(s) to reset |
// 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.
Argument | Type | Description |
facet | integer|string | Facet id or slug |
// 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.
Argument | Type | Description |
facet | integer|string | Facet id or slug |
// 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.
Argument | Type | Description |
facet | string | Facet slug |
wpgb.facets.getParams( 'facet_slug' );
hasParams()hasParams()
This methods allows to check if a facet has parameters (selected values).
Argument | Type | Description |
facet | string | Facet slug |
wpgb.facets.hasParams( 'facet_slug' );
setParams()setParams()
This methods allows to assign parameters (selected values) to a facet.
Argument | Type | Description |
facet | string | Facet slug |
params | array | Holds facet parameters as string |
wpgb.facets.setParams( 'facet_slug', ['param1', 'param2'] );
deleteParams()deleteParams()
This methods allows to delete parameters (selected values) from a facet.
Argument | Type | Description |
facet | string | Facet slug |
params | array | Holds facet parameters as string |
wpgb.facets.deleteParams( 'facet_slug', ['param1'] );