# AJAX filter

# Basic usage

As an example, let's add an update via AJAX to standard thread filters. This requires only one modification to the forum_filters template:

Search type: Regular expression.
Find:

/(<xf:form action="{{ link\('forums\/filters', \$forum\) }}")(>)/

Replace:

<xf:js src="TC/ComponentLibrary/ajax_filter.js" addon="TC/ComponentLibrary" min="1" />

$1 data-xf-init="tc-ajax-filter" data-filter-url="{{ link('forums', $forum) }}" data-replace=".js-threadList"$2

Пример
Пример

# TeslaCloud.AjaxFilter (tc-ajax-filter)

# Arguments

Argument Default value Description
filterUrl null URL for submitting the filter form.
filterContainer null Selector for filter container. If not specified, the handler target is used as the container.
replace null Selector for updating content.
scrollTarget Selector for scrolling after content update.
updateDelay 250 Delay before filtering after filter change.
autoSubmit true If true, submitting the form with filters will happen automatically after changing any filter, otherwise the form must be submitted manually.
hideSubmit false If true, all elements with type="submit" will be hidden in the form.