I confirmed that my form is never submitted (Controller never been called) and I see no error in the upload JS script. But here is the result of console.log and alerts I get from each method:
Expand|Select|Wrap|Line Numbers
- add: function (e, data) {
- //this seems to work fin
- var tpl = $('<li class="working"><input type="text" value="0" data-width="48" data-height="48"'+
- ' data-fgColor="#0788a5" data-readOnly="1" data-bgColor="#3e4043" /><p></p><span></span></li>');
- // Append the file name and file size
- tpl.find('p').text(data.files[0].name)
- .append('<i>' + formatFileSize(data.files[0].size) + '</i>');
- // Add the HTML to the UL element
- data.context = tpl.appendTo(ul);
- // Initialize the knob plugin
- tpl.find('input').knob();
- // Listen for clicks on the cancel icon
- tpl.find('span').click(function(){
- if(tpl.hasClass('working')){
- jqXHR.abort();
- }
- tpl.fadeOut(function(){
- tpl.remove();
- });
- });
- // Automatically upload the file once it is added to the queue
- console.log("submitting selected images");
- //behaving as expected
- var jqXHR = data.submit();
- },
- done: function (e, data) {
- console.log("done event reached");
- //not entering this event AT ALL
- //REDIRECT
- },
- progress: function(e, data){
- //This one logs progress as 100, 95,3 etc for one file. I assume that is also expected behaviour tho I found it odd it starts with 100 and goes down. I am uploading only one file to try.
- var progress = parseInt(data.loaded / data.total * 100, 10);
- data.context.find('input').val(progress).change();
- if(progress == 100){
- data.context.removeClass('working');
- }
- console.log("progress");
- },
- fail:function(e, data){
- // This is logged if I refresh the page only (to try again).
- console.log(data.context);
- console.log('fail event fired');
- data.context.addClass('uploadError');
- },
- success:function(e, data){
- //file uploaded awesome
- //this event never reached.
- },
- always:function(e, data){
- //file uploaded awesome
- //this fires only if I hit the refresh button to reload the page again
- alert(data);
- }