- see https://gist.github.com/machty/5723945 for the latest API (unlikely to change from now on)
- latest Ember build: https://machty.s3.amazonaws.com/ember/ember-async-routing-10.js
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
class AnonymousUser < User | |
attr_accessible *ACCESSIBLE_ATTRS, :type, :token, as: :registrant | |
def register(params) | |
params = params.merge(type: 'User', token: nil) | |
self.update_attributes(params, as: :registrant) | |
end | |
end |
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 get = Ember.get, set = Ember.set, doc = document; | |
var FastSelectComponent = Ember.Component.extend({ | |
items: null, | |
valuePath: 'value', | |
labelPath: 'label', | |
value: null, | |
selected: null, | |
tagName: 'select', |
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
/* basic usage */ | |
ViewGroup root = (ViewGroup) findViewById(android.R.id.content); | |
LayoutTraverser.build(new LayoutTraverser.Processor() { | |
@Override | |
public void process(View view) { | |
// do stuff with the view | |
} | |
}).traverse(root); |
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
// enable keyboard shortcuts in views | |
Ember.View.reopen({ | |
bindKey: function (shortcut, action) { | |
var controller = this.controller; | |
window.key(shortcut, function () { | |
controller.send(action); | |
}); | |
}, | |
unbindKey: function (shortcut) { | |
window.key.unbind(shortcut); |
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
// Extend Ember.Route to add support for sensible | |
// document.title integration. | |
Ember.Route.reopen({ | |
// `titleToken` can either be a static string or a function | |
// that accepts a model object and returns a string (or array | |
// of strings if there are multiple tokens). | |
titleToken: null, |
-
Data Down / Actions Up
- http://emberjs.jsbin.com/nayaho/edit?html,js - Interdependent select boxes. No observers.
- http://ember-twiddle.com/2d7246875098d0dbb4a4 - One Way Input
-
Plain JSBin's
-
Ember Version Base JSBin's
Consider the example:
var MyObject = Ember.Object.extend({
selectedContent: Ember.computed.filterBy('content', 'isSelected')
});
var obj = MyObject.create({
content: [
Em.Object.create({name: "one", isSelected: false}),
Em.Object.create({name: "two", isSelected: false})
OlderNewer