Skip to content

Instantly share code, notes, and snippets.

@kevinansfield
Created November 1, 2012 10:42
Show Gist options
  • Select an option

  • Save kevinansfield/3992996 to your computer and use it in GitHub Desktop.

Select an option

Save kevinansfield/3992996 to your computer and use it in GitHub Desktop.
Ember view - unable to access controller?
Chapters.EditChapterView = Ember.View.extend
templateName: 'chapters/edit'
tagName: 'form'
classNames: 'form-horizontal'
didInsertElement: ->
@_super()
@$('input:first').focus()
submit: (event) ->
event.preventDefault()
@get('controller').updateRecord()
imagePicker: Ember.View.extend
tagName: 'div'
template: Ember.Handlebars.compile "
<input type=\"hidden\" {{bindAttr value=\"parentView.thumbnail_url\"}} />
<a href=\"#\" class=\"btn\">Pick File</a>
<span>{{parentView.thumbnail_url}}</span>
"
filepicker_options:
mimetype: 'image/*'
services: ['COMPUTER','FACEBOOK','INSTAGRAM','URL','WEBCAM']
openTo: 'COMPUTER'
click: (event) ->
event.preventDefault()
filepicker.pick(@filepicker_options, @filepickerSuccess, @filepickerError)
filepickerSuccess: (file) ->
# @get('controller').setImage(file.url)
Chapters.router.editChapterController.setImage(file.url)
filepickerError: (error) ->
console.log error.toString()
@kevinansfield
Copy link
Author

Updated to access the controller instance directly through the router, is this standard practice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment