Skip to content

Instantly share code, notes, and snippets.

@dmitryd
Created April 24, 2015 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitryd/21cb0eee72113d877069 to your computer and use it in GitHub Desktop.
Save dmitryd/21cb0eee72113d877069 to your computer and use it in GitHub Desktop.
TYPO3 Solr: modify selected facet link to serve as a reset link using jQuery
(function($) {
$(document).ready(function() {
/**
* Turns the currently active facet link to "reset facet" link by removing the filter segment.
*/
function modifyFacetLinkToReset() {
if (document.location.search.indexOf('tx_solr%5Bfilter%5D') > 0) {
$('.tx-solr-collapsible-facets a').each(function() {
if (this.href.indexOf(document.location.search) > 0) {
this.href = this.href.replace(/tx_solr%5Bfilter%5D[^&]+&?/, '');
}
});
}
}
modifyFacetLinkToReset();
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment