Koha ILS

Remove Parenthesis from Koha URLs with JQuery

Today’s guest post comes from Christopher Brannon at Cooperative Information Network (CIN).

We were running into issues in which Koha’s subject links with parenthesis would have no results. Removing the parenthesis from the URLs makes it work. This is the best solution I’ve found so far. Unfortunately it isn’t as straight forward as replacing the parenthesis with spaces, because some extra spaces in the URL also end up breaking the search. So, I had to get a little creative.

[code language=”javascript” wraplines=”true” toolbar=”true”]
//Fix subject search by striping parenthesis from url links
$(‘#catalogue_detail_biblio a[href*="su:"]’).attr(‘href’, function(_,v){

return v.replace(/(\w)(\(|\))(\w)/g,’$1 $3′)

}).attr(‘href’, function(_,v){

return v.replace(/(\(|\))/g,”)

//End fix subject search

Read more by ByWater Partners

Tags jquery tutorial