Skip to content

Instantly share code, notes, and snippets.

@mattbeedle
mattbeedle / gist:c34058ab1b7882e5a1b8
Created May 26, 2014 05:24
Getting ember-easyForm to display errors returned from 422 responses
# This is a little ember easyform hack to make errors display when the form is
# submitted
Ember.EasyForm.Input.reopen
errorsChanged: (->
@set('hasFocusedOut', true)
@showValidationError()
)
didInsertElement: ->
@addObserver("context.errors.#{@property}.@each", @, 'errorsChanged')
@Blackmist
Blackmist / ember-model-wam.js
Created May 13, 2013 15:40
Ember-model-based adapter that uses the Windows Azure Mobile Services client.
// ember-model-based adapter
Ember.WAMAdapter = Ember.Object.extend({
table: null,
init: function() {
this.table = this.get('table');
},
find: function(record, id) {
var query = this.table.where({ id: id });
return query.read().then(function(data) {
@Genkilabs
Genkilabs / autosavable.js
Last active January 3, 2016 03:49
Debounced Autosave for EmberJS using 1.2.0-beta.4 and EmberData 1.0.0-beta.4+canary.3993001d with hooks for pacifier from http://ricostacruz.com/nprogress
// Debounced autosave for Ember.js
// Original code by Mitch Lloyd http://gaslight.co/blog/?author=mitchlloyd
// updated from http://gaslight.co/blog/an-autosave-pattern-for-ember-and-ember-data
// repo at https://github.com/gaslight/ember-autosaving
// Changed to work with latest Ember Data as of 2013-12-16 by Genkilabs
// Includes hooks for pacifier from http://ricostacruz.com/nprogress
// NOTE: This requires a 2 part install in which the controller and any models it loads have the corresponding mixin
// This is how long we will wait on a form before saving. I like to put this in App.AUTOSAVE_DELAY
var AUTOSAVE_DELAY = 1500
@ivanvanderbyl
ivanvanderbyl / account_routes.js
Last active January 31, 2016 17:55
Using Ember initializers and injections to setup the `currentUser` within your app.
App.AccountEditRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('content', this.get('currentUser'));
}
});
.form-group
label
| Time Zone
time-zone value=model.timezone
@tim-evans
tim-evans / autosave.js
Created June 14, 2013 16:03
Autosave pattern for Ember with Ember Data
(function () {
// Implement debounce until backburner implements a proper debounce
var debouncees = [],
pop = Array.prototype.pop;
var debounce = function (target, method /*, args, wait */) {
var self = Ember.run.backburner,
args = arguments,
wait = pop.call(args),
/* global google */
var GoogleMapComponent = Ember.Component.extend({
places: [],
width: 500,
height: 500,
attributeBindings: ['style'],
style: function () {
return 'width:'+this.width+'px; height:'+this.height+'px';
@pamelafox
pamelafox / view.html
Created August 21, 2012 14:30
Google Maps AutoComplete for Profile Location Field
<div class="control-group">
<label class="control-label">Location</label>
<div class="controls">
<input name="location" type="text" placeholder="City, State, Country" value="">
<input name="location_city" type="hidden" value="">
<input name="location_state" type="hidden" value="">
<input name="location_country" type="hidden" value="">
<input name="location_lat" type="hidden">
<input name="location_lng" type="hidden">
</div>
@machty
machty / document-title-router.js
Created January 14, 2014 05:12
document.title integration in ember
// 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,
@andruby
andruby / deploy.rb
Created January 26, 2011 19:48
Start and Stop tasks for resque workers, with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}"