Filters /

JavaScript Functions

The following JavaScript functions are available when using the Filters add-on:


almfilters.start()

TheĀ almfilters.start(target) function will initiate an Ajax Load More filter instance.

target: The unique filter ID (optional).

almfilters.start( 'categories' );
JavaScript

Note: start() is useful if filters have been loaded via Ajax or another client-side render method.


almfilters.reset()

The almfilters.reset() function will clear and reset an entire Ajax Load More filter instance.

let clearBtn = document.getElementById('clear-filters');
clearBtn.addEventListener('click', function(e){
   almfilters.reset();
});
JavaScript

almfilters.resetFilter()

The resetFilter() function will clear and reset a specific filter group.

window.almFiltersChange = function(){
   var filter = document.querySelector('.alm-filter[data-key=search]');
   almfilters.resetFilter(filter);
}
JavaScript

Note: resetFilter() is useful when you want to clear a specific filter while performing another task.


almfilters.getActiveFilters()

The almfilters.getActiveFilters() function will parse the current URL querystring and return an object containing all the currently active filters.

const filters = almfilters.getActiveFilters();
if(filters){
   console.log(filters);
   // Do something with the object results.
}
JavaScript

« Back to Filters