0
我想打電話給name變量是內部功能 mycollection.fetch()。其實每當我試圖聲明name變量 全球範圍內它不能正常工作。先謝謝你。我想打電話給一個變量的函數外Backbone.js的
var MyModel = Backbone.Model.extend({
defaults: {
"id": "",
"name": ""
}
});
var MyCollection = Backbone.Collection.extend({
url: "http://ec2-54-186-169-140.us-west-2.compute.amazonaws.com/automation-poc-api/list",
model: MyModel,
parse : function(response){
return response;
//api returns objects in the content attribute of response, need to override parse
}
});
var myCollection = new MyCollection();
myCollection.fetch({
success: function(col) {
// console.log(col.toJSON()[0].lists[0].name);
var name=col.toJSON()[0].lists[0].name;
}
});
你說什麼,當你說,**我想調用名稱變量**? – Cyclone
var名字裏面是成功函數。我想在函數外部訪問這個變量@Cyclone –
window.name在這裏不工作 –