Вопрос

Am I doing something completely wrong here? I am populating a backbone model from a jsonp response. When I view the first console statement in firebug, the 'current' object has 'icon' under attributes. However, when printing console.log(current.has("icon")) it returns false and therefore current.get("icon") will return undefined.

var Current = Backbone.Model.extend({
    url: "A_valid_url",
    sync: function(method, model, options) {
        options.timeout = 10000;
        options.dataType = "jsonp";

        return Backbone.sync(method, model, options);
    },
    parse: function(response, xhr) {
        return response.current_observation;
        }
});

var current = new Current({test: "blah"});
    current.fetch();
    console.log(current);//under attributes there is a "icon"
    console.log(current.has("icon")); //false
    console.log(current.get("icon")); //undefined
    console.log(current.has("test")); //true

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top