Answers.Body: <p>That's a good idea. Here is a refinement of your patch that works it into core using <code>localStorage</code>, which is not CMS dependent.</p>
  
  <p><a href="https://github.com/civicrm/civicrm-core/pull/8485" rel="nofollow">https://github.com/civicrm/civicrm-core/pull/8485</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-03T22:17:23.543Z
Answers.LastActivityDate: 2016-06-03T22:17:23.543Z
Answers.UserDisplayName: Coleman
Body: <p>While cleaning our contacts database, our users claimed that it would be beneficous to have the quick search bar remember the type of field to search in. In many cases it's helpfull to repeatedly search for zip codes or email addresses or stuff like that. </p>
  
  <p>I had no luck finding information about accessing civi's session with js and therefore I wondered how to implement and decided to walk the extension way by feeding drupal with a cookie in my module's js file. What do you think? </p>
  
  <pre><code>CRM.$(document).ready(function () {
      /** 
       * Save quick search type on select
       */
      CRM.$('.crm-quickSearchField').click(function() {
          var label = CRM.$(this).text();
          var value = CRM.$('input', this).val();
          jQuery.cookie('quickSearchLabel', label);
          jQuery.cookie('quickSearchType', value);
      });
  
      /**
       * Set quick search type on load
       */
      var quickSearchType = jQuery.cookie('quickSearchType');
      if (quickSearchType) {
          var quickSearchLabel = jQuery.cookie('quickSearchLabel');
          var label = quickSearchLabel ? quickSearchLabel : "Suche";
          var value = quickSearchType;
          // These fields are not supported by advanced search
          if (value === 'first_name' || value === 'last_name') {
              value = 'sort_name';
          }
          KompiModsLib.radioSelect("input[name=quickSearchField]", value);
          CRM.$('#sort_name_navigation').attr({name: value, placeholder: label}).focus();
      }
  });
  </code></pre>
  
  <p>And: would it be valuable to add it to the core?</p>
  
Tags: <search><ui><core>
Title: Sticking quick search target tyoe
ThreadText: # Sticking quick search target tyoe
  
  (Asked by: username_0 on 2016-06-03)
  
  While cleaning our contacts database, our users claimed that it would be beneficous to have the quick search bar remember the type of field to search in. In many cases it's helpfull to repeatedly search for zip codes or email addresses or stuff like that. 
  I had no luck finding information about accessing civi's session with js and therefore I wondered how to implement and decided to walk the extension way by feeding drupal with a cookie in my module's js file. What do you think? 
  CRM.$(document).ready(function () {
      /** 
       * Save quick search type on select
       */
      CRM.$('.crm-quickSearchField').click(function() {
          var label = CRM.$(this).text();
          var value = CRM.$('input', this).val();
          jQuery.cookie('quickSearchLabel', label);
          jQuery.cookie('quickSearchType', value);
      });
  
      /**
       * Set quick search type on load
       */
      var quickSearchType = jQuery.cookie('quickSearchType');
      if (quickSearchType) {
          var quickSearchLabel = jQuery.cookie('quickSearchLabel');
          var label = quickSearchLabel ? quickSearchLabel : "Suche";
          var value = quickSearchType;
          // These fields are not supported by advanced search
          if (value === 'first_name' || value === 'last_name') {
              value = 'sort_name';
          }
          KompiModsLib.radioSelect("input[name=quickSearchField]", value);
          CRM.$('#sort_name_navigation').attr({name: value, placeholder: label}).focus();
      }
  });
  
  And: would it be valuable to add it to the core?
  
  **Tags:** search, ui, core
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-06-03. Score: 1 | Accepted answer
  
  That's a good idea. Here is a refinement of your patch that works it into core using `localStorage`, which is not CMS dependent.
  
  <https://github.com/civicrm/civicrm-core/pull/8485>
  
  
  ---
  
  