function getArrivals() {
//$('#container').empty();
// can we query multiple locids?? then do this:
var locIDs = ['2580'];
var locIDsString = locIDs.join();
//end
var trimetURL = 'http://developer.trimet.org/ws/V1/arrivals/locIDs/' + locIDs[0] + '/appID/5E48DCD7031297B7CBF2F37FD?json=true';
var result;
$.ajax({
async: false,
type: "GET",
url: trimetURL,
dataType: 'json',
success: function (data) {
result = (JSON.stringify(data.resultSet));
},
error: function (e) {
console.log('error', e);
},
complete: function () {
}
});
return result;
}
var Person = Backbone.Model.extend({
defaults: {
name: 'default name',
age: 99,
job: 'default job'
},
validate: function (attr) {
console.log('attr', attr);
if (attr.age < 0 || attr.name == "Steve") {
return "VALIDATION ERROR: You can't be negative years old";
}
},
initialize: function () {
//this.on('change:age', function (model) {});
this.validate();
}
});
var homeView = Backbone.View.extend({
el: $('#container'),
initialize: function () {
this.render();
},
render: function () {
var data = getArrivals();
// console.log('data', data);
this.$el.html('hello bb');
}
});
var h = new homeView();
var person = new Person();
person.set({
name: 'Steve',
age: 29
});
person.set({
age: -100
});
person.bind("error", function (model, error) {
// We have received an error, log it, alert it or forget it :)
alert(error);
});
console.log(person.toJSON(), person.attributes);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.