Skip to content

Instantly share code, notes, and snippets.

@mnutt
Created August 25, 2013 19:56
Show Gist options
  • Save mnutt/6335921 to your computer and use it in GitHub Desktop.
Save mnutt/6335921 to your computer and use it in GitHub Desktop.
Ember Modal Component test. The component takes a 'title' property and generates a button. When you click the button, it creates a dynamic child view appended to the body yielding whatever content was passed into the component block.
{{#modal-popup title="Edit Pic"}}
<!-- this goes inside the modal -->
<div class='pic'>
<div class="form">
{{input value=pic.url}}
</div>
</div>
{{/modal-popup}}
ModalPopupComponent = Em.Component.extend
showModal: ->
@createChildView(Em.View,
classNames: ['modal-popup-container']
controller: @_parentView.get('controller')
context: @_parentView.get('context')
template: @get('template')
templateData: { keywords: @_parentView.cloneKeywords() }
popupHide: -> @remove()
isModal: true
).append()
export default ModalPopupComponent
{{#if isModal}}
<div class="modal-popup">
{{yield}}
</div>
{{else}}
<button {{action showModal}}>{{title}}</button>
{{/if}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment