Modify placeholder for Search widget

1550
1
Jump to solution
06-02-2017 02:38 PM
TracySchloss
Frequent Contributor

I have my Search widget defined as

var searchTool = new Search({
 map: map,
allPlaceholder: "Find address or ZIP"
 }, dom.byId('searchDiv'));

The placeholder seems to be ignored, it still says "Find address or place" which is the default.  The majority of my users don't understand they can use this field to search by ZIP code, so I need to change this.

It seems like this used to say simply placeholder, not allPlaceholder in previous versions.  

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Tracy,

   That only works when you have more than one source for the Search widget. If you are only working with one source then you have to modify the default localization string:

      require([
        "esri/map",
        "esri/dijit/Search",
        "dojo/i18n!esri/nls/jsapi",
        "dojo/domReady!"
      ], function (Map, Search, esriBundle) {
         esriBundle.widgets.Search.main.placeholder = "blah";
         var map = new Map("map", {
            basemap: "gray",
            center: [-120.435, 46.159], // lon, lat
            zoom: 7
         });

         var search = new Search({
            map: map
         }, "search");
         search.startup();
      });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

1 Reply
RobertScheitlin__GISP
MVP Emeritus

Tracy,

   That only works when you have more than one source for the Search widget. If you are only working with one source then you have to modify the default localization string:

      require([
        "esri/map",
        "esri/dijit/Search",
        "dojo/i18n!esri/nls/jsapi",
        "dojo/domReady!"
      ], function (Map, Search, esriBundle) {
         esriBundle.widgets.Search.main.placeholder = "blah";
         var map = new Map("map", {
            basemap: "gray",
            center: [-120.435, 46.159], // lon, lat
            zoom: 7
         });

         var search = new Search({
            map: map
         }, "search");
         search.startup();
      });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍