Skip to content

Instantly share code, notes, and snippets.

@jasonporritt
Created April 27, 2013 15:32
Show Gist options
  • Save jasonporritt/5473506 to your computer and use it in GitHub Desktop.
Save jasonporritt/5473506 to your computer and use it in GitHub Desktop.
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