AnsweredAssumed Answered

How to handle QueryTask call back function in AMD module?

Question asked by sanjayjadhav on Jan 30, 2015
Latest reply on Jan 30, 2015 by sanjayjadhav

Hello,

 

I have just started learning ArcGIS API For JavaScript and Dojo AMD and I'm stuck on an issue of callback function of a query task.

 

I have a simple html page and couple of custom AMD modules inside a folder.Below is my folder structure.

 

Folder Structure.png

Below is my AMD module for querying feature layer added to map and I call function "queryStatesLayer" from my index.html page.

 

define(["esri/tasks/QueryTask","esri/tasks/query","dojo/_base/lang"],function(QueryTask,Query,lang){     return{    queryStatesLayer:function (sqlString,Layer,outFlds){    var query,queryTask;    //initialize query task   queryTask = new QueryTask(Layer.url);    //initialize query   query = new Query();   query.returnGeometry = true;   query.outFields = outFlds;    //execute query   queryTask.execute(query,showResults);   },    //query completed Callback function.   showResults: function(qryResults){   alert("Query Completed..");  } ...    }; }); //define function ends..

 

Now,my problem is I'm not being able to figure out how should I write my query completed call back function in my module.I know that the way it is written now will not be called when query is completed. And if I write it as simple function outside of return { };it not recognized and I get an error in the console of Mozilla Firefox.

 

I would appreciate if I could get guidance on this issue.I want to write my query completed callback function in my custom AMD module.

 

S.

Outcomes