Select to view content in your preferred language

dynamic html cannot access js function inside dojo "requires function"

2613
0
08-26-2014 10:28 AM
DerekLoi
Regular Contributor

i have a javascript function inside the dojo.requires function:

 

for instance:

 

require(["esri/map"], function(Map) {       function switchService(servicename) {           alert("hello world");      }       function listServices() {           var html = "";           var results = // list of services returned from json file           //loops thru list            for (var i=0; i<results.length-1; i++) {                html += '<input checked name="radioService" id="chk_' + serviceName + '" style="margin-left: 15px;" type="radio" value="' + serviceName + "|" + results + '" onclick="switchServices(this.value);" />';           }           document.getElementById('divMapServices').innerHTML = html;      }  }

 

everything works great once i move the switchService function outside of the dojo requires function. However after switching services, i am rebuilding the layers list for the new service and which is located back inside the requires function.  thus i cannot accees the buildlayers function since my scope is now outside the requires function... hope that makes sense... lol

 

i've been reading up on dojo and modules... so i might rewrite everything to go that route... however, if anyone has a solution, please let me know

0 Kudos
0 Replies