Tech Blog

Automatically Activate A Search After Changing Search Scope

The default behaviour of the Primo new UI forces users to click on the search button after changing the search scope. This piece of Angular/JavaScript changes the behaviour so that the search results are reloaded after changing scope from the drop down menu automatically


//component to activate search when search scope changed updated 09/11/17 DW
      bindings: {parentCtrl: '<'},
      controller: function($scope){
                     function activateSearch(){
                 document.getElementsByClassName("zero-margin button-confirm md-button md-primoExplore-theme")[0].click()
                 }, 500)
                  var searchScopes = document.querySelectorAll('[id^="select_option_"]')
            for (var i in searchScopes){
                searchScopes[i].onclick = function(){
                              }, 500)


3 Replies to “Automatically Activate A Search After Changing Search Scope”

  1. We’ve been unable to get this to work. The search appears to run when you switch the scope, but the results remain the same as the prior search; you still have to click the search icon to get results from the new scope.

    By Stacy Magedanz on June 21, 2017 at 7:46 PM

  2. The code has been updated with an additional timeout added to ensure the correct results are returned for each scope when they are changed.

    By Duncan Wilson on November 9, 2017 at 10:03 AM

Leave a Reply