Created
August 7, 2013 18:42
-
-
Save blackjk3/6177127 to your computer and use it in GitHub Desktop.
Ember Starter with rest.
This file contains 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
App = Ember.Application.create({ | |
rootElement: '.affix-container', | |
ready: function() { | |
console.log('ember ready'); | |
App.requestController = App.RequestController.create(); | |
} | |
}); | |
DS.RESTAdapter.reopen({ | |
namespace: 'portal/requests/api' | |
}); | |
DS.RESTAdapter.registerTransform('object', { | |
deserialize: function(serialized) { | |
return Em.isNone(serialized) ? {} : serialized; | |
}, | |
serialize: function(deserialized) { | |
return Em.isNone(deserialized) ? {} : deserialized; | |
} | |
}); | |
App.Store = DS.Store.extend({ | |
adapter: DS.RESTAdapter | |
}); | |
App.Request = DS.Model.extend({ | |
active: DS.attr('boolean'), | |
created_on: DS.attr('date'), | |
modified_on: DS.attr('date'), | |
project: DS.attr('object') | |
}); | |
App.RequestController = Ember.ObjectController.extend({ | |
init: function() { | |
console.log('init controller'); | |
}, | |
fetch: function(id) { | |
this.set('model', App.Request.find(id) ); | |
} | |
}); | |
$(function() { | |
console.log('dom ready'); | |
App.requestController.fetch(10621); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment