Is it possible to override the new Home button's popup text?

1399
3
Jump to solution
09-29-2013 05:17 PM
StephenLead
Regular Contributor III
The new Home button automatically inserts a div into the page with these values:

 <div class="homeContainer">   <div class="home" data-dojo-attach-event="ondijitclick:home" role="button" title="Default extent" data-dojo-attach-point="_homeNode">     <span>Home</span>   </div> </div>


Is it possible to modify the title text ("Default extent")? If not, could we have this added as a parameter during construction?

Thanks,
Steve
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Frequent Contributor
You can change the home button's alt text the same way you change text or a label for any other widget in the API:  use dojo/i18n ot load and get a reference to the API's collection of text strings and change widgets.homeButton.home property to be whatever you like. Here's code to do this:

require([   "esri/map",    "esri/dijit/HomeButton",   "dojo/i18n!esri/nls/jsapi",   "dojo/domReady!" ], function(   Map, HomeButton, esriBundle )  {   esriBundle.widgets.homeButton.home.title = "Custom home button text.";    var map = new Map("map", {     center: [-56.049, 38.485],     zoom: 3,     basemap: "streets"   });            var home = new HomeButton({     map: map   }, "HomeButton");   home.startup();  });


I don't think we currently have this in our docs and we'll get it added.

View solution in original post

0 Kudos
3 Replies
JasonZou
Occasional Contributor III
This should work.

var djtHomeButton = new HomeButton({
    map: map
}, "HomeButton");
djtHomeButton._homeNode.title = "This is the new title";
djtHomeButton.startup();
0 Kudos
StephenLead
Regular Contributor III
Thanks. Hopefully Esri will add an official parameter to the API sometime.
0 Kudos
derekswingley1
Frequent Contributor
You can change the home button's alt text the same way you change text or a label for any other widget in the API:  use dojo/i18n ot load and get a reference to the API's collection of text strings and change widgets.homeButton.home property to be whatever you like. Here's code to do this:

require([   "esri/map",    "esri/dijit/HomeButton",   "dojo/i18n!esri/nls/jsapi",   "dojo/domReady!" ], function(   Map, HomeButton, esriBundle )  {   esriBundle.widgets.homeButton.home.title = "Custom home button text.";    var map = new Map("map", {     center: [-56.049, 38.485],     zoom: 3,     basemap: "streets"   });            var home = new HomeButton({     map: map   }, "HomeButton");   home.startup();  });


I don't think we currently have this in our docs and we'll get it added.
0 Kudos