Algolia autocomplete – function footerTemplate causes SCRIPT1010: Expected Identifier error

I’m using Algolia autocomplete (JQuery).

It works perfectly on Chrome, Firefox etc, but Internet Explorer 11

On IE, it causes the SCRIPT1010: Expected Identifier error, from the line with function footerTemplate

I have no idea what to do about this; any advice would be much appreciated. Thanks

Here’s some excerpts from my code:

var client = algoliasearch('{{ getenv('ALGOLIA_APP_ID') }}', '{{ getenv('ALGOLIA_PUBLIC') }}');
                var index_classes = client.initIndex('classes');
                var index_stories = client.initIndex('articles');

jQuery(function($) {
                var client = algoliasearch('{{ getenv('ALGOLIA_APP_ID') }}', '{{ getenv('ALGOLIA_PUBLIC') }}');
                var index_classes = client.initIndex('classes');
                var index_stories = client.initIndex('articles');

                if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
                    nr_res = 3;
                    nr_res_2 = 1;
                } else {
                    nr_res = 5;
                    nr_res_2 = 5;
                }

                $('input[name="search_text"]').autocomplete(
                    { debug:true,
                        templates: {
                            footer: ''
                        }
                    }, [
                        {
                            source: $.fn.autocomplete.sources.hits(index_classes, { hitsPerPage: nr_res }),
                            displayKey: 'name',
                            name: 'class',
                            templates: {
                                header: '
Classes (top ' + nr_res + ')
', suggestion: function(suggestion) { return '<img src="/images/class/' + suggestion.id + '_100.jpg">' + '
' + suggestion._highlightResult.name.value + '' + suggestion._highlightResult.teacher_name.value + ''; }, empty: '
No results. See all classes
', footer: function footerTemplate({ query, isEmpty }) { if (!isEmpty) { $('#see-all-sr').show(); } } } }, { source: $.fn.autocomplete.sources.hits(index_stories, { hitsPerPage: nr_res_2 }), displayKey: 'title', name: 'story', templates: { header: '
Stories (top ' + nr_res_2 + ')
', suggestion: function(suggestion) { return '<img src="/images/article/' + suggestion.id + '_100.jpg">' + '
' + suggestion._highlightResult.title.value + '' + suggestion._highlightResult.author_name.value + '
'; }, empty: '
No results. See all stories
', footer: function footerTemplate({ query, isEmpty }) { if (!isEmpty) { $('#see-all-sr').show(); } } } } ]).on('autocomplete:selected', function(event, suggestion, dataset) { // https://github.com/algolia/autocomplete.js#jquery window.location = '/' + suggestion.url; }).on('autocomplete:empty', function() { $('#see-all-sr').hide(); });

});

Source: stackoverflow-javascript