rapportive-oss / jquery-fuzzymatch

A command-t/quicksilver inspired string ranking algorithm for autocompletion.
MIT License
30 stars 10 forks source link

I get an error: #1

Open ccorcos opened 10 years ago

ccorcos commented 10 years ago

Uncaught TypeError: undefined is not a function fuzzy.js?9fd92688852714542edcf93e036b4aea0d3d9104:82

TravisSpangle commented 10 years ago

I got this error as well. When I switched to the full version the exception happened to me on line 82 for the function:

function allCaseInsensitiveSplits(string, chr)

It failed because string was a 0 and the function being called was for a string data type not a number.

To resolve it I played with the example code and it appears to be wrong. Instead of passing 'a' you want to pass 'this'.

So

callback($(['dog', 'cat', 'cow']).filter(function (a) {
                // Only show items which match
                return $.fuzzyMatch(a, context.term).score;

needs to be

callback($(['dog', 'cat', 'cow']).filter(function (a) {
                // Only show items which match
                return $.fuzzyMatch(this, context.term).score;

This corrected the problem for me.