PDA

View Full Version : problems with jsonp



ainden
18 Jan 2012, 7:09 PM
Am trying to use the "feed-viewer" example app to evaluate ext-4.0.7. I wanted to implement a JSONP backend.





Ext.define('FV.model.Feed', {
extend: 'Ext.data.Model',


proxy: {
type: 'jsonp',
writer: 'json',
api: {
create : '../feed/createRecord',
read : '../feed/readRecord',
update : '../feed/updateRecord',
destroy : '../feed/destroyRecord'
},


reader: {
type: 'json',
root: 'feedInstanceList'
}
},
fields: [
{name: 'url', type: 'string'},
{name: 'name', type: 'string'}

]
});



When I click remove feed button the removeFeed method in the controller is executed and fails on store.remove(feed).



removeFeed: function() {
var feed = this.getFeedData().getSelectionModel().getSelection()[0];
var store = this.getFeedsStore();
store.remove(feed);
},


The console says "TypeError: Result of expression 'operation' [undefined] is not an object." at line ext-all-debug-w-comments.js:39526. Which is the first line of the build request method in "Ext.data.proxy.Server"



buildRequest: function(operation) {

var params = Ext.applyIf(operation.params || {}, this.extraParams || {}),
request;


//copy any sorters, filters etc into the params so they can be sent over the wire
params = Ext.applyIf(params, this.getParams(operation));


if (operation.id && !params.id) {
params.id = operation.id;
}


request = Ext.create('Ext.data.Request', {
params : params,
action : operation.action,
records : operation.records,
operation: operation,
url : operation.url
});


request.url = this.buildUrl(request);


/*
* Save the request on the Operation. Operations don't usually care about Request and Response data, but in the
* ServerProxy and any of its subclasses we add both request and response as they may be useful for further processing
*/
operation.request = request;


return request;
},



Which is called by the subclass "Ext.data.proxy.JsonP" destroy method via the this.callParent() method.


destroy: function() {
this.abort();
this.callParent();
},




I think this is a bug. The operation object is null. I have walked through the stack and I cannot see where it would be set. The callParent method does not pass the arguments object.


I am stumped. Can anyone help? Thanks....

lorezyra
18 Jan 2012, 7:21 PM
Check your scoping and vars...
Setup a console.warn() on your vars in the removeFeed() function...

e.g.)



removeFeed: function() {
if ( Ext.isGecko ) {
console.warn("this");
console.dir(this);
console.warn("this.getFeedData()");
console.dir(this.getFeedData());
}
var feed = this.getFeedData().getSelectionModel().getSelection()[0];
var store = this.getFeedsStore();
store.remove(feed);
},

skirtle
18 Jan 2012, 8:04 PM
From a look through the source I'm inclined to agree, this is a bug. In 4.1.0-beta-1 the destroy method looks like this:


destroy: function() {
this.abort();
this.callParent(arguments);
},