Last active
November 20, 2015 05:12
-
-
Save spencer516/48a64fc6f767eebe9f2a to your computer and use it in GitHub Desktop.
New Twiddle
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
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
import Ember from 'ember'; | |
export default Ember.TextField.extend({ | |
keyUp() { | |
var value = this.get('value'); | |
var notify = this.getAttr('notify'); | |
var isValid = this.validate(value); | |
debugger | |
notify(value, isValid); | |
}, | |
validate(value) { | |
return value.indexOf('t') > -1; | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
buffer: null, | |
bufferJSON: '', | |
notify(path, value, isValid) { | |
var buffer = this.get('buffer'); | |
this.set('buffer.'+path, {isValid, value}); | |
this.set('bufferJSON', JSON.stringify(buffer)); | |
this.set('notValid', !this.checkIsValid(buffer)); | |
}, | |
checkIsValid(buffer) { | |
return Object.keys(buffer).every(key => { | |
return buffer[key].isValid; | |
}); | |
}, | |
flushBuffer() { | |
var buffer = this.get('buffer'); | |
this.set('buffer', {}); | |
Object.keys(buffer).forEach(key => { | |
// Do something here to add/update this | |
// item in the array. | |
}); | |
}, | |
notValid: true, | |
init() { | |
this._super(); | |
this.set('buffer', {}); | |
}, | |
actions: { | |
save() { | |
this.flushBuffer(); | |
} | |
} | |
}); |
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
{ | |
"version": "0.4.16", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment