Fix #497: Remove erroneous doSearch() call on document ready#502
Open
manvirsingh01 wants to merge 1 commit intosugarlabs:masterfrom
Open
Fix #497: Remove erroneous doSearch() call on document ready#502manvirsingh01 wants to merge 1 commit intosugarlabs:masterfrom
manvirsingh01 wants to merge 1 commit intosugarlabs:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 definedThe Fix
The erroneous $(document).ready() call that invoked doSearch() globally has been removed.