Select to view content in your preferred language

Capture name of ersi.dijit.BookmarkItem on click

882
1
02-10-2012 01:13 PM
BenjaminZank1
Deactivated User
Hello,
I have created a application and have used the bookmarks widget to add 20 some odd custom bookmarks to the map within a "dijit.TooltipDialog" drop-down list (as the online sample shows). I can connect to the esri.dijit.Bookmarks onClick event to run functions when the user selects a bookmark from the list. What I would like to do to do extract the "name" of the BookmarkItem that was selected by the user after each on click event and pass it into a variable. Does anyone know if this is possible?

Thanks,
Benjamin Zank
0 Kudos
1 Reply
AndyGup
Esri Regular Contributor
@BenJamin to get information on what item is clicked in the bookmark dijit try adding an onClick event listener to the bookmarks <div>. If try to use dojo.connect(bookmark, 'onClick', someFunction); you won't get the correct scope. For example, here is some psuedo-code, however note that this will pick up "any" click that occurs including the "Add Bookmark" button. So when you build this into your app you'll need to filter what comes back by using something like a switch/case statement:

<script>
function bookmarkClickHandler(evt){
    console.log("bookmark " + evt.target.innerText);  
}
</script>

<div id="bookmarks-pane" 
  data-dojo-type="dijit.TitlePane" 
  data-dojo-props='title:"Bookmarks",
  tooltip:"I\"m the tooltip for Title Pane #1\"s title bar" '>
 
 <div id="bookmarks" onClick="bookmarkClickHandler(evt)"></div>
 <button id="clear-storage">Remove Map Bookmarks</button>
</div>
0 Kudos