Last active
June 21, 2017 13:40
-
-
Save ivan-marquez/51035b854a28571876380232e24cb8b8 to your computer and use it in GitHub Desktop.
JQuery fileUpload attach form values to submit
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
$('#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