Skip to content

Instantly share code, notes, and snippets.

@kevinold
Created January 14, 2015 04:18
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 kevinold/d7368d20c41d845bcd11 to your computer and use it in GitHub Desktop.
Save kevinold/d7368d20c41d845bcd11 to your computer and use it in GitHub Desktop.
/**
* @jsx React.DOM
*/
var Attachment = React.createClass({
getDefaultProps: function() {
return {
'preventCaching': false,
'buttonText': I18n.t('defaults.browse'),
'debug': false,
'width': 61,
'height': 24,
'multi': true,
'queueID': false
};
},
getInitialState: function() {
return {
'attachment[intent]': false
};
},
componentDidMount: function() {
var upload_field = jQuery(this.refs.fileInput.getDOMNode());
upload_field.uploadify({
'buttonText': this.props.buttonText,
'button_image_url': '',
'debug': this.props.debug,
'swf':'/swf/uploadify.swf',
'preventCaching': this.props.preventCaching,
'uploader': this.props.uploader_url,
'auto':true,
'fileObjName': this.props.input_name,
'width': this.props.width,
'height': this.props.height,
'multi': this.props.multi,
'queueID': this.props.queueID,
'formData': this._formData,
'onUploadSuccess': function (fileObj, data, response) {
eval(data);
return true;
},
'onQueueComplete': false
});
},
render: function() {
return (
<div>
<input ref="fileInput" className="" id={this.props.input_name} name={this.props.input_name} type="file" />
</div>
);
},
_formData: function(){
var session_token = encodeURIComponent($("meta[name=csrf-token]").attr('content'));
var data = {
'authenticity_token': session_token,
'authenticity_token_once': session_token,
COUPA_SESSION_PARAM: COUPA_SESSION_TOKEN
};
return data;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment