App.Profile = DS.Model.extend({
});
App.User = DS.Model.extend({
profile: DS.belongsTo(App.Profile)
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
### Keybase proof | |
I hereby claim: | |
* I am ghempton on github. | |
* I am gordon (https://keybase.io/gordon) on keybase. | |
* I have a public key whose fingerprint is D4FB AED6 9E30 D434 AC3D 17E3 E406 8EA9 1729 1FD0 | |
To claim this, I am signing this object: |
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
// dynamically creating classes + computed properties | |
// result of ajax request, these are the fields and their dependencies | |
var fields = {'name': {'firstName', 'lastName'}}; | |
var mixin = {}; | |
for(var name in fields) { | |
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
test("Grandparent route context change", function() { | |
expect(0); | |
Ember.TEMPLATES.application = compile("{{outlet}}"); | |
Ember.TEMPLATES.posts = compile("{{outlet}}"); | |
Ember.TEMPLATES.post = compile("{{outlet}}"); | |
Ember.TEMPLATES.show = compile("showing"); | |
Ember.TEMPLATES.edit = compile("editing"); | |
Router.map(function(match) { | |
match("/").to('index'); |
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
Ember.Route.reopen({ | |
enter: function(router) { | |
this._super(router); | |
if(this.get('isLeafRoute')) { | |
var path = this.absoluteRoute(router); | |
mixpanel.track('page viewed', {'page name' : document.title, 'url' : path}); | |
_gaq.push(['_trackPageview', path]); | |
} | |
} | |
}); |
Currently, there are several awkward points to Ember.js controllers. Namely:
- Passing controllers around to view's not instantiated by the routing system is hard.
- Non-singleton controllers are very difficult to manage (e.g. #each where each view has it's own controller).
- Sharing data between controllers is difficult.
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
# Small extension to create a clone of the element without | |
# metamorph binding tags and ember metadata | |
$.fn.extend | |
safeClone: -> | |
clone = $(@).clone() | |
# remove content bindings | |
clone.find('script[id^=metamorph]').remove() | |
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
// This file contains utilities for creating bound helpers | |
// For reference: https://github.com/wagenet/ember.js/blob/ac66dcb8a1cbe91d736074441f853e0da474ee6e/packages/ember-handlebars/lib/views/bound_property_view.js | |
Ember.Handlebars.BoundHelperView = Ember.View.extend(Ember._Metamorph, { | |
context: null, | |
options: null, | |
property: null, | |
// paths of the property that are also observed | |
propertyPaths: [], |
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
var get = Ember.get, set = Ember.set, computed = Ember.computed; | |
export default Ember.Component.extend({ | |
tagName: 'a', | |
classNameBindings: ['isActive:active'], | |
attributeBindings: ['href'], | |
href: null, | |
emberRouteName: null, | |
router: computed(function() { |
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
/** | |
Attempting to create a subclass of `Model` that supports | |
CP's and Ember.Observable. | |
*/ | |
function EmberModel() { | |
Model.apply(this, arguments); | |
return CoreObject.apply(this); | |
} | |
var PrototypeMixin = Model.prototype; |
NewerOlder