mercredi 16 septembre 2015

handling a jsonp callback in an ember component

I have a jsonp request to retrieve feature information via geoserver, the call looks something like this:

import Ember from 'ember';

export default Ember.Component.extend({

  _selectParcel: function() {

    function handleJson(data){
      console.log(data);
    }

    $.ajax('url/geoserver/wms', {
      type: 'GET',
      data: {
      service: 'WFS',
      version: '1.1.0',
      request: 'GetFeature',
      typeName: 'name_here',
      maxFeatures: 10000,
      outputFormat: 'text/javascript',
      srsname: 'EPSG:4326',
      bbox: '-73.68229866027832, 40.97056664236637, -73.68229866027832, 40.97056664236637, EPSG:4326'
    },
      dataType: 'jsonp',
      jsonpCallback: 'callback:handleJson',
      jsonp: 'format_options'
    });

  }
});

The problem that I run into is dealing with the callback scope - in this case, handleJson()

I have also tried

.then(function(){});

after the ajax call but with no luck.

_selectParcel is going to be called frequently based on mouse movement.

How do should the jsonp callback be handled within the Ember component?

I've seen this using ember data with jsonp but im not sure how to interact with an adapter from the component.




Aucun commentaire:

Enregistrer un commentaire