Ok, I came across the answer: -
After several studies, I found that this user in Google forums also has the same problem.
Simply put, how this works, you use <script> to create your search bar.
You have this function + html element for your search bar
<script> (function() { var cx = '###'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//cse.google.com/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:searchbox-only resultsUrl="/search-results"></gcse:searchbox-only>
So, we created a bar in our <div class="header"> , which is a HAML element as part of the template. Therefore, it was always loaded into every header. Since we have 10 pages, this same script was created 1 time per page.
Our Google CSE is created for search, and then redirected to URL /search-results , where it generates results.
To generate the results, you need this function and HTML
<script> (function() { var cx = '###'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//cse.google.com/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script>
This is the same as the one loaded in our header. With this setting, the results page will call this <script> twice at startup and cause a JS break. Therefore, after removing the <script> load of the results, he stopped throwing an error.
To make this concise, just make sure you don't call the same function twice on the results page, and it should clear up Uncaught TypeError .
Not. Reiteration. Independently
- ether