Skip to content

inteference between two typeaheads on same page with dynamicFilter  #505

@tamw

Description

@tamw

Hi,
I seem to have the same problem as mentioned in issue #200 in the comments. The original issue may be fixed but the 'related?' one in the comment still seems broken in version 2.11.00:

Apparently I get the same error when I have two typeaheads with dynamicFilter on 1 page ???

If I have two typeaheads on the same page both using a dynamicFilter, when the second initialises it has this.dynamicFilter.isEnabled = true ... which causes data to load before the container is set resulting in,

Uncaught TypeError: Cannot read property 'addClass' of null
    at Typeahead.generateSource (jquery.typeahead.js:846)
    at Typeahead.set (jquery.typeahead.js:2962)

I fixed locally by adding this line number 223:

this.displayEmptyTemplate;          // Display the empty template in the result list
this.dynamicFilter.isEnabled = false; //20200805 TRW: Bug fix?: clear the dynamic filter from earlier typeaheads before constructing the new one
this.__construct();

I'm not sure that's the best fix, but it works for me as far as I can tell.

I hope I've logged this in the right way - I'm new to this. Sorry I can't easily attach code snippet from my code. If needed I'll construct a simple example to help check it is an issue and resolve.

Thanks for a great plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions