1

I'm not sure how to replicate this problem with just a code snippet, because it involves so many different elements of my HTML and JS. So here is a jsbin with the whole code.

I use ESRI's popup widget to populate the sidebar with data from the selected feature, and it works. Except for one bit where I'm running a function pctile after selecting the feature (line 1376 in my JavaScript).

pctile should give me a value P that is the percentile rank of the currently selected tract.

If you watch the console while clicking census tracts in the map, you can see that line 1408 writes the value P of the previously selected tract ("P from buildHeader"). After that, the function pctile fires, updating the value of P to the current tract ("P:").

How can I ensure that pctile fires and updates P before I try to use it in my function buildHeader (line 1403)?

UPDATE I think the solution involves using callbacks. I'm trying to make that work now.

Update I have tried using callbacks, but I'm not sure that solution works in this context. Because the function I want to pass as the callback argument is my buildHeader function that returns HTML to insert into a div. From what I understand you can't get a return from a callback function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.