Why don't jQuery File Upload plugin's process events trigger?

I have a weird problem with jQuery File Upload plugin. If I use this sitax:

  url: myurl,
  add: function(e, data){
    console.log("add event");
  processalways: function(e, data){
    console.log("processalways event");

processalways event don't occur, but I got correct data.context variable (i.e. the div with the progress bar of the added file).

While when I use this sintax

  url: myurl
}).on('fileuploadadd',function(e, data){
    console.log("add event");
}).on('fileuploadprocessalways', function(e, data){
    console.log("processalways event");

processalways event correctly occur, but I got wrong data.context (I think in this case data.context will always refer to $('fileupload') element.

I need both process event and data.context variable. How can I do?


First syntax

If you want to start the process you have to call data.submit(); into the add fnction.

Then you can't call a processalways callback, according to the documentation it's always which should be used :

    url: "/echo/json",
    add: function (e, data) {
        console.log("Add callback");
    always: function (e, data) {
        console.log("Always callback");

Second syntax

I've never use it, but if it works it's because fileuploadd doesn't exist. And so it's the default fileuploadadd which is used, and it may call data.submit().

I had read a bit code in jquery.fileupload-ui.js

Maybe this is what you want?

// The add callback is invoked as soon as files are added to the fileupload
// widget (via file input selection, drag & drop or add API call).
// See the basic file upload widget for more information:
add: function (e, data) {
    if (e.isDefaultPrevented()) {
        return false;
    var $this = $(this),
        that = $this.data('blueimp-fileupload') ||
        options = that.options;
    data.context = that._renderUpload(data.files)
        .data('data', data)
        options.prependFiles ? 'prepend' : 'append'
    data.process(function () {
        return $this.fileupload('process', data);
    }).always(function () {
        data.context.each(function (index) {
    }).done(function () {
        data.context.find('.start').prop('disabled', false);
        if ((that._trigger('added', e, data) !== false) &&
            (options.autoUpload || data.autoUpload) &&
            data.autoUpload !== false) {
    }).fail(function () {
        if (data.files.error) {
            data.context.each(function (index) {
                var error = data.files[index].error;
                if (error) {

Need Your Help

Qt QApplication::processEvents() in custom event handler

events qt event-handling long-running-processes

Is it possible to call QApplication::processEvents() inside the event handler, where there is a long process. My program terminates with Segfault. My code is something like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.