Last active
August 29, 2015 14:19
-
-
Save megalithic/fec3d38cfbb560e98cc8 to your computer and use it in GitHub Desktop.
ampersand view, having a time with model data fetching and binding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AmpersandModel = require('ampersand-model'); | |
var config = require('clientconfig'); | |
var Status = require('./status'); | |
var StatusModel = new Status(); | |
var ItineraryModel = AmpersandModel.extend({ | |
props: { | |
uuid: ['string', true, ''], | |
userId: ['string', true, ''], | |
expiredAt: ['string', true, ''], | |
items: ['array', true, function() { return []; }] | |
}, | |
children: { | |
status: Status | |
}, | |
urlRoot: config.apiUrl + '/itinerary', | |
ajaxConfig: function() { | |
return { | |
xhrFields: { | |
responseType: "json" | |
}, | |
useXDR: true | |
} | |
} | |
}); | |
module.exports = ItineraryModel; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PageView = require('./base'); | |
var templates = require('../templates'); | |
module.exports = PageView.extend({ | |
prop: { | |
status: 'object' | |
}, | |
autoRender: false, | |
pageTitle: 'my itinerary', | |
template: templates.pages.myItinerary, | |
bindings: { | |
'model.status.message': '[data-hook~=status-message]', | |
'model.status.code': '[data-hook~=status-code]' | |
}, | |
render: function () { | |
this.renderWithTemplate(); | |
this.fetchItinerary(); | |
}, | |
fetchItinerary: function () { | |
this.model.fetch(); | |
this.model.status.fetch(); | |
return false; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment