-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
@lewismoten commented on Wed Oct 12 2016
I'm having a bug pop up. this.parseModel is undefined. This happens when an ajax request completes in jQuery, and CanJS has a proxy to convert the response to a model. In this case, "this" represents the CanJS "Map"
jquery.js - Callback for a completed ajax request...
complete( // complete === jquery.js done
xhrSuccessStatus[ xhr.status ] || xhr.status, // 200
xhr.statusText, // "OK"
( xhr.responseType || "text" ) !== "text" ||
typeof xhr.responseText !== "string" ?
{ binary: xhr.response } :
{ text: xhr.responseText }, // {text: '{"name": "value"}'}
xhr.getAllResponseHeaders() // Pragma: no-cache, etc.
); jquery.js - done
response = ajaxConvert( s, response, jqXHR, isSuccess );
// ajaxConvert === jquery.js ajaxConvert
// s === (ajax options)
// response === {error: "SyntaxError: Unexpected token o in JSON", state: "parsererror"}
// jqXHR === jqXHR...
// isSuccess === truejquery.js - ajaxConvert:
response = conv( response );
// response ==={error: "..."}
// conv === can/proxy.js class_cbcan/construct/proxy/proxy.js - class_cb
cur = (isString ? self[func] : func).apply(self, cur || []);
// self = Map
// func = "model"
// cur = [{error: "..."}]Which essentially translates to:
Map.model.call(Map, {error: "..."})can/model/model.js - model
attributes = this.parseModel(attributes, xhr);
// this === Map
// attributes === {error: "..."}
// xhr === undefined
// this.parseModel === undefinedHow can I get "Map" to have "parseModel"?
It appears that this may be a work-around...
attributes = function(attributes){
return function (attributes) {
return prop ? can.getObject(prop, attributes) : attributes;
};
};
//attributes = this.parseModel(attributes, xhr);@justinbmeyer commented on Tue Apr 11 2017
@lewismoten Anyway you can create an example? Moving to can-model.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels