1. #1
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Vote Rating
    2
    smokeman is on a distinguished road

      0  

    Default callback function

    callback function


    forgive me, but I'm struggling with MVC a bit.

    I have a function I've defined in my controller, to get the mileage between 2 cities from google.
    I get loc1, and loc2 from a gridpanel, with a rowediting plugin.
    I added an edit event to the rowediting plugin, which is where I get the editor.record.data values to pass to this function.

    I'm trying to return the value back to the edit event function, and I can't seem to figure out how to do a callback with architect.

    Code:
    getgmapsdistance:function(loc1,loc2){
    var geocoder, location1, location2, gDir;
    
    geocoder = new GClientGeocoder();
    gDir = new GDirections();
    GEvent.addListener(gDir, "load", function() {
        var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
        var gmiles = drivingDistanceMiles;
        //return gmiles;
    });
    var adr1=loc1 + ', AR, USA';
    var adr2=loc2 + ', AR, USA';
    geocoder.getLocations(adr1, function (response) {
        if (!response || response.Status.code != 200)
        {
            console.log("Sorry, we were unable to geocode the first address");
        }
        else
        {
            location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
            geocoder.getLocations(adr2, function (response) {
                if (!response || response.Status.code != 200)
                {
                    console.log("Sorry, we were unable to geocode the second address");
                }
                else
                {
                    location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
                    gDir.load('from: ' + location1.address + ' to: ' + location2.address);
    
                }
            });
        }
    });
    }
    I'm sure it's simple, I just can't figure it out.

    here's the way I'm calling the function:
    Code:
    onGridroweditingpluginEdit:function(editor,e,options){
    MyApp.controller.MyControllers.prototype.getgmapsdistance(editor.record.data.Td_trfrom,editor.record.data.Td_trto);

  2. #2
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Vote Rating
    2
    smokeman is on a distinguished road

      0  

    Default other approaches

    other approaches


    I'd still be interested in other approaches, but I solved my issue by passing the entire record to the getdistance function, and once I got a google maps distance, I updated the data record with a rec.set(field,gdistance);

    I'm sure my problem here, is from the value coming from the .load listener, so the only way I could think of to solve it was setting the value inside that function.

    I'd still like to see a callback example in MVC

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."