I'm having trouble getting $('.drop').attr('data-id') in formData:
$('.drop').fileupload({
dataType: 'json',
url: base_path + 'parallax/upload',
autoUpload: false,
replaceFileInput: false, // interferes w/ dropify
formData: {
id: $('.drop').attr('data-id'), // nothing
stmt: '1', // works
'{/literal}{$this->security->get_csrf_token_name()}{literal}': '{/literal}{$this->security->get_csrf_hash()}{literal}'
},
add: function (d, c) {
console.log($(this).attr('data-id')); // works
console.log($('.drop').attr('data-id')); // works
console.log($('#fileupload').attr('data-id')); // works
var a = [];
var b = /\.(gif|jpe?g|png)$/i;
if (c.originalFiles[0]['name'].length && !b.test(c.originalFiles[0]['name'])) {
a.push('Not an accepted file type.');
}
if (c.originalFiles[0]['size'].toString().length && c.originalFiles[0]['size'] > maxsize) {
a.push('Filesize is too big; try increasing post_max_size and/or upload_max_filesize.');
}
if (a.length > 0) {
bootbox.alert(a.join(''));
} else {
start_time = new Date().getTime();
c.submit();
}
},
According to the docs, additional form data can be added via:
$('#fileupload').fileupload({
formData: {example: 'test'}
});
Which works for my csrf token and other things I manually define, however I cannot seem to get the data-id of the input field in formData. No errors are occurring, but I do see my request being sent without the id attribute - if I manually define it - it works. I can also get the property in the add function.
Whats going on?