documentcloud / visualsearch

A Rich Search Box for Real Data
http://documentcloud.github.com/visualsearch
MIT License
1.8k stars 237 forks source link

TypeError: this.box.data(...) is undefined #129

Closed Ciwan1859 closed 10 years ago

Ciwan1859 commented 10 years ago

Hello

I have never used this before, but thought I would give it a try. I have added all required dependencies (latest of each), but when I run my page, I get the following error:

TypeError: this.box.data(...) is undefined.

The line of code is:

// Renders the results grouped by the categories they belong to. this.box.data('ui-autocomplete')._renderMenu = function(ul, items) { var category = '';

Any help would be greatly appreciated.

Thank You.

samuelclay commented 10 years ago

Is this my code or your code? As for this.box being undefined, check your reference and see what the this keyword points to.

Ciwan1859 commented 10 years ago

Hi Samuel, Merci for the reply.

Assuming you're the only one working on VisualSearch.js, then yes this would be your code :)

I did as you suggested, and placed a break-point in Chrome debugger on that line, and got the following:

visualsearcherror

The code again is below:

        this.box.data('ui-autocomplete')._renderMenu = function(ul, items) {
            var category = '';
            _.each(items, _.bind(function(item, i) {
                if (item.category && item.category != category) {
                    ul.append('<li class="ui-autocomplete-category">'+item.category+'</li>');
                    category = item.category;
                }

                if(this._renderItemData) {
                    this._renderItemData(ul, item);
                } else {
                    this._renderItem(ul, item);
                }

            }, this));
        };
Ciwan1859 commented 10 years ago

It turns out my dependencies were not correct in terms of their versions.

Note to everyone reading this ... to ensure you get no headaches, use the dependencies file that comes with the download of Visual Search.

Thanks