Fixed the search function

Posted on Thu 20 March 2014 in News • 1 min read

I got around to fixing the broken search engine today. Turned out to be simpler than I thought but since JavaScript isn't my forte it took much longer than it should have.

Turns out that the content of the search box wasn't being passed properly to the JavaScript function that handles it. The offending line of JavaScript was:

JsonSearch($('#search_field').attr('value'), ['title', 'content']);

For some reason .attr('value') was passing an empy string to the function, JsonSearch. Maybe it's my fault for using Safari but it's JavaScript debugger was decidedly unhelpful at locating the source of the problem. All it threw was a rather unhelpful and non-descriptive error. Anyway, once I found that problem, I changed the offending line to:

JsonSearch($('#search_field').val(), ['title', 'content']);

That seems to have fixed the problem. It was likely my fault for breaking it the first place. I've been adapting this site's engine from the excellent work of Simon Jodet and along with updating Bootstrap to version 3.1.1 I've also linked to the latest version of Jquery which may explain why .attr('value') doesn't work for me. At this point in time I have neither the patience or desire to find out why.

Share on: Diaspora*TwitterFacebookGoogle+Email