Skip to content

Instantly share code, notes, and snippets.

@ivan-marquez
Last active June 21, 2017 13:40
Show Gist options
  • Save ivan-marquez/51035b854a28571876380232e24cb8b8 to your computer and use it in GitHub Desktop.
Save ivan-marquez/51035b854a28571876380232e24cb8b8 to your computer and use it in GitHub Desktop.
JQuery fileUpload attach form values to submit
$('#file').fileupload({
url: 'rewards/postnotes',
singleFileUploads: true,
replaceFileInput: false,
fileInput: $('#file'),
type: 'POST',
autoUpload: false,
progressall: function (e, data) {
button.attr('disabled', 'disabled')
},
success: function (e, data) {
button.removeAttr('disabled')
$('#file').attr('disabled', 'disabled')
rewards.store.dispatch(actionCreator.fetchMeasure($('#measure-id').val()))
renderMessage('success', 'Document successfully uploaded', 'Dynamics CRM')
},
error: function (err) {
renderMessage('error', 'Error uploading document', 'Dynamics CRM')
button.removeAttr('disabled')
},
add: function (e, data) {
button.off('click').on('click', function () {
data.submit()
})
}
})
$('#file').bind('fileuploadsubmit', function (e, data) {
data.formData = getMeasure()
if (!data.formData.id) {
data.context.find('button').prop('disabled', false)
return false
}
})
function getMeasure () {
return {
id: $('#').val(),
measure: $('#').val()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment