Skip to content

Instantly share code, notes, and snippets.

@mib32
Created September 27, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mib32/dac06c41344b178407ad to your computer and use it in GitHub Desktop.
Save mib32/dac06c41344b178407ad to your computer and use it in GitHub Desktop.
#= require jquery
#= require bootstrap
#= require ./application-view
@Modal = ApplicationView
getStores: ->
ModalStore
getPropsFromStores: ->
ModalStore.getState()
onChange: (state) ->
this.setState(state)
if _.any(state.htmlContent)
window.ReactRailsUJS.mountComponents(@getDOMNode())
$(@element()).modal('show')
else
$(@element()).modal('hide')
openState: ->
unless "#{@state.htmlContent}" is '' then 'in' else ''
rawMarkup: ->
__html: @state.htmlContent
render: ->
if typeof(@state.htmlContent) != 'string'
header = <div className="modal-header" dangerouslySetInnerHTML={{__html: @state.htmlContent.header}}></div>
body = <div className="modal-body" dangerouslySetInnerHTML={{__html: @state.htmlContent.body}}></div>
footer = <div className="modal-footer" dangerouslySetInnerHTML={{__html: @state.htmlContent.footer}}></div>
content = <div className="modal-content">{header}{body}{footer}</div>
console.log('obj')
else
console.log('str')
content = <div className="modal-content" dangerouslySetInnerHTML=@rawMarkup()></div>
<div className="modal fade #{@openState()}">
<div className="modal-dialog">
{ content }
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment