I already asked how to toggle an identify button in a previous question, and was given the correct answer to the question, but when I tried to implement it into a toolbar that would disable the identify button when another button was pressed it didn't work. I guess I should have asked the question a little better. I am hoping that soneone will be able to help put the two pieces of code together. An example can be found at the following link and my code is below.
http://geoville.org/viewers/PopUp/
Identify with Popup
Thanks to those that can help and thanks to those that helped with the previous question.
-Mike
Answer
Ok, you are needing to add some additional logic to know what other buttons are activated and toggle on and off as needed. Something like this:
function updateTool(theDijit) {
var zoominDij, zoomoutDij, panDij, idDij, itemArray;
zoominDij = dijit.byId("zoomin");
zoomoutDij = dijit.byId("zoomout");
panDij = dijit.byId("pan");
idDij = dijit.byId("identify");
itemArray = [zoominDij, zoomoutDij, panDij, idDij];
if (theDijit.attr("id") != "identify")
identifyDisconnect();
for (var i = 0; i < itemArray.length; i++) {
if (theDijit.attr("id") == itemArray[i].attr("id")) {
theDijit.attr("checked", true);
} else {
itemArray[i].attr("checked", false);
itemArray[i].focus();
}
}
}
You will need a little work on your itemArray to have the right button IDs as well as inside where you set the trigger to disable the other functions.
Coupled with a call like this on your toolbar buttons:
onclick="identifyConnect();updateTool(this);"
Now this additional call will set a value of what button was clicked, will help you disconnect the function from one and allow you to set active to the other. This is what I use on my productions sites like here Washington State Sales Tax.
No comments:
Post a Comment