Solved! Go to Solution.
var buttonclick;
function buttoncall() { buttonclick = dojo.connect(map, "onClick" resultFunction); } function resultFunction() { dojo.disconnect(buttonclick); alert("test"); }
require([ ], function( ) {
Hi Jay,
Here is an example that sets the infoTemplate each time the button is clicked.
<input type="button" id="button" value="Identify" />
on(dom.byId("button"), "click", function () { featureLayer.setInfoTemplate(template); initializeSidebar(app.map); on(app.map.infoWindow, "show", function () { featureLayer.setInfoTemplate(null); }) }) function initializeSidebar(map){ var popup = map.infoWindow; //when the selection changes update the side panel to display the popup info for the //currently selected feature. connect.connect(popup, "onSelectionChange", function(){ displayPopupContent(popup.getSelectedFeature()); }); //when the selection is cleared remove the popup content from the side panel. connect.connect(popup, "onClearFeatures", function(){ //dom.byId replaces dojo.byId dom.byId("featureCount").innerHTML = "Click to select feature(s)"; //registry.byId replaces dijit.byId registry.byId("leftPane").set("content", ""); domUtils.hide(dom.byId("pager")); }); //When features are associated with the map's info window update the sidebar with the new content. connect.connect(popup, "onSetFeatures", function(){ displayPopupContent(popup.getSelectedFeature()); dom.byId("featureCount").innerHTML = popup.features.length + " feature(s) selected"; //enable navigation if more than one feature is selected popup.features.length > 1 ? domUtils.show(dom.byId("pager")) : domUtils.hide(dom.byId("pager")); }); } function displayPopupContent(feature){ if(feature){ var content = feature.getContent(); registry.byId("leftPane").set("content", content); } }
var buttonclick; function buttoncall() { buttonclick = dojo.connect(map, "onClick" resultFunction); } function resultFunction() { dojo.disconnect(buttonclick); alert("test"); }
This should work for either one...
Create a global variablevar buttonclick;
Then create the function the button callsfunction buttoncall() { buttonclick = dojo.connect(map, "onClick" resultFunction); } function resultFunction() { dojo.disconnect(buttonclick); alert("test"); }
Give it a shot
<a href="javascript:buttoncall()" id="button1" ><img alt="button1IMG" id="button1IMG" style="bottom:10px; left: 10px; width:36px; position:absolute; z-index:22; border:none;" src="images/Button.png"/></a>
dojo.disconnect(buttonclick);
buttonclick = dojo.connect(map, "onClick", resultFunction);