Created
September 27, 2015 09:39
-
-
Save mib32/dac06c41344b178407ad to your computer and use it in GitHub Desktop.
This file contains 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
#= 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