Created
April 27, 2013 15:32
-
-
Save jasonporritt/5473506 to your computer and use it in GitHub Desktop.
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
App.DynamicBoundTextField = Ember.TextField.extend | |
placeholderBinding: 'content.name' | |
# Update the remote property's value when the value of | |
# our text field changes | |
_setRemoteValue:(-> | |
val = @get('value') | |
@set("controller.data.#{@get('content.key')}", val) if val? | |
).observes('value') | |
# Since we don't know the name of the property to | |
# observe ahead of time, create the observer when | |
# inserted into the DOM (we'll have the key then). | |
didInsertElement: -> | |
updateCurrentValue = => | |
currentValue = @get("controller.data.#{@get('content.key')}") | |
console.log currentValue | |
@set('value', currentValue) if currentValue? | |
updateCurrentValue() | |
@addObserver "controller.data.#{@get('content.key')}", updateCurrentValue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment