AMD - Using ESRI JSAPI 1.3 classes

Discussion created by ihatem on Aug 6, 2012
Latest reply on Sep 6, 2012 by DSwingley-esristaff
I followed the link below from ESRI help to use AMD to build a class that calls a find task. The link below uses the seatGeek api and not ESRI JSAPI classes.I am having issues getting the callback function processResults called. Does this programming pattern work with ESRI Javascript api ? I am 100 percent sure that the find task returns a response and I can see it in firebug. The callback function of the find task just never fires. If i create an instance of the class do find fires but the return is empty.Please advise


dojo.declare("esric.find", null, {

    findTask: null,
    findParams: null,
    esricMap: null,
    results: null,

    constructor: function (options) {
        //specify class defaults

        esricMap = options.aMap

        //Create Find Task using the URL of the map service to search
        findTask = new esri.tasks.FindTask("http://server1/arcgis/rest/services/esric/TLGIS/MapServer");

        //Create the find parameters
        findParams = new esri.tasks.FindParameters();
        findParams.returnGeometry = true;
        findParams.layerIds = [5];
        findParams.searchFields = ["STATION_JUNCTION_NAME"];
        findParams.outSpatialReference = options.aMap.spatialReference;

        // dojo.hitch is to provide the proper context so that processResults
        // will have access to the instance of this class

                this.processResults = dojo.hitch(this, this.processResults);


    doFind: function () {

        findParams.searchText = "LARCHWOOD TS";
        var eventsResponse = findTask.execute(findParams);
        return eventsResponse.then(this.processResults, this.err);

    processResults: function (response) {
        results = response;
        return response;
    err: function (anError) {