Skip to content

Fix #497: Remove erroneous doSearch() call on document ready#502

Open
manvirsingh01 wants to merge 1 commit intosugarlabs:masterfrom
manvirsingh01:issue-497-fix-doSearch-not-defined
Open

Fix #497: Remove erroneous doSearch() call on document ready#502
manvirsingh01 wants to merge 1 commit intosugarlabs:masterfrom
manvirsingh01:issue-497-fix-doSearch-not-defined

Conversation

@manvirsingh01
Copy link

In index.html (lines 107–111), there was a script block that attempted to call doSearch() when the document was ready:
$(document).ready(function () { doSearch(); });

However, doSearch is not a global function. It is defined as an instance method inside the Activity class in js/activity.js:
this.doSearch = () => { // autocomplete search logic... };

Since doSearch is scoped to the Activity instance (this.doSearch), it cannot be accessed directly from index.html. This resulted in the runtime error:

Uncaught ReferenceError: doSearch is not defined

The Fix

The erroneous $(document).ready() call that invoked doSearch() globally has been removed.

The doSearch() function is a method of the Activity class, not a global
function. Calling it in .ready() caused an Uncaught ReferenceError.

The doSearch() method is properly called from within showSearchWidget()
after the search widget and suggestions are properly initialized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant