Skip to content

Instantly share code, notes, and snippets.

View zoghal's full-sized avatar
🏠
Working from home

Saleh Souzanchi zoghal

🏠
Working from home
View GitHub Profile
@zoghal
zoghal / index.md
Created June 4, 2012 18:56 — forked from lancejpollard/index.md
Notes on Ember.js overcomplicating...

Some random notes on the pangs of ember. Will be expanding as they are uncovered.

Building a form

Say you have a form that maps to a model, something like:

<form>
  <fieldset>
    <legend>Who are you?</legend>
@zoghal
zoghal / app.js
Created June 4, 2012 18:58 — forked from olivoil/app.js
ember.js login form
App = Ember.Application.create({});
App.loginController = Ember.Object.create({
// do login stuff
});
App.LoginFormView = Ember.View.extend({
login: null,
password: null,
@zoghal
zoghal / gist:2870212
Created June 4, 2012 19:06 — forked from seth-macpherson/gist:2473961
Ember.js tree
<html>
<head>
<script src="javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="javascripts/ember.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
App = Ember.Application.extend();
App.Node = Ember.Object.extend({
name: null,
@zoghal
zoghal / gist:2870224
Created June 4, 2012 19:09 — forked from rickard2/gist:2390740
EmberJS Data handling
window.App = Ember.Application.create({});
Item = Ember.Object.extend({
});
App.ListController = Ember.ArrayController.create({
content: [],
currentItem: null,
findAll: function(store, type) {
var root = this.rootForType(type);
this.ajax(root, "GET", {
success: function(json) {
store.loadMany(type, json["objects"]);
store.typeMapFor(type).modelArrays.forEach( function(item) {
item.set('isLoaded', true);
});
@zoghal
zoghal / loginState.js
Created June 4, 2012 19:53
Ember.js login animations
App.LoginState = Ember.State.extend({
enter: function() {
App.loginView = App.LoginView.create();
App.loginView.appendTo('#content.container');
},
submit: function(a, params) {
App.loginView.loggingIn();
@zoghal
zoghal / app.js
Created June 4, 2012 20:21 — forked from johanvalcoog/app.js
ember.js login form
App = Ember.Application.create({});
App.loginController = Ember.Object.create({
// do login stuff
});
App.LoginFormView = Ember.View.extend({
login: null,
password: null,
@zoghal
zoghal / coffeescript
Created June 4, 2012 20:35 — forked from krisselden/gist:1473687
Ember ajax wrapper
App.ajax = (url, settings)->
deferred = $.Deferred()
settings.xhr = ->
xhr = $.ajaxSettings.xhr()
if 'onprogress' of xhr
context = this
xhr.onprogress = (e)->
Ember.run(deferred, deferred.notifyWith, context, [e.loaded/e.total])
xhr
jqXHR = $.ajax(url, settings)
Species = DS.Model.extend({
name: DS.attr('string')
});
Person = DS.Model.extend({
name: DS.attr('string'),
species: DS.belongsTo(Species, { embedded: true })
tags: DS.hasMany(Tag, { embedded: true })
});
@zoghal
zoghal / gist:2918210
Created June 12, 2012 15:31 — forked from xdissent/gist:2860403
Ember-data hasMany computed properties test
test("filtered property on hasMany assoctiation", function() {
var File = DS.Model.extend({
primaryKey: 'name',
name: DS.attr('string'),
status: DS.attr('string')
});
var Project = DS.Model.extend({
primaryKey: 'name',