0

being not that much of a js guy using http://fineuploader.com/demos.html gave me a good headstart getting fineuploader working in the citadel webinterface. My last issue which I fail to achieve is getting a deleteComplete hook registered (as documented here: http://docs.fineuploader.com/api/events.html#deleteComplete ) I'm probably missing some domain specific vocabulary, so my general question is, how does one specify event handlers, the deleteComplete one in specific.

My need is to call update_attachment_count() which should refresh the number of attachments uploaded for the mail being composed in the main screen.

so far I've got (we don't use jquery):

<script type="text/javascript">
function createUploader()
{
    var uploader = new qq.FineUploader(
    {
        session: {
        endpoint: "do_template?template=edit_message_json_attlist"
        },
        callbacks: {
        onComplete: update_attachment_count,
        delete: update_attachment_count,
        deleteComplete: update_attachment_count
        },
        element: document.getElementById('fine-uploader'),
        request: {
        endpoint: 'upload_attachment?nonce=<?NONCE>&template=edit_message_upl_att'
        },
        deleteFile: {
        enabled: true,
        forceConfirm: true,
        endpoint: 'remove_attachment?nonce=<?NONCE>&template=edit_message_upl_att&which_attachment='
        }
    });
}

  window.onload = createUploader;
</script>
<div id="fine-uploader"></div>
...
<script type="text/javascript"> 

    function update_attachment_count() {
        p = 'r=' + CtdlRandomString();
        new Ajax.Updater(
            'num_attachments',
            'show_num_attachments',
            {
                method: 'get',
                parameters: p
            }
        );
    }

</script>
</div>

TIA, and thanks a lot for making Fineuploader available.

dothebart
  • 5,972
  • 16
  • 40
  • We've added some additional clarification to the documentation. Please have a look and let us know if there is anything else we can improve in this area. – Ray Nicholus Jan 27 '14 at 23:22
  • Yes, this makes it clear. I guess what I was missing was the bridge between 'callback' and 'events'. The snippets solve this in a good way. – dothebart Jan 30 '14 at 07:14

1 Answers1

0

I'm not clear on what you're trying to do exactly with the event handlers, but here is the correct syntax for the three you specified above.

// ...
callbacks: {
    onComplete: function (id, name, responseJSON, xhr) {
        console.log("Upload completed for fileid: " + id);
    }
    onDelete: function (id) {
        console.log("About to send delete request for fileid: " + id);
    },
    onDeleteComplete: function (id, xhr, isError) {
        console.log("Deletion completed for fileid: " + id);
    }
},
// ...

For jQuery events, see FineUploader OnComplete not being called.

Need FineUploader Method uploadStoredFiles to Complete Before Proceeding will get you started on updating the UI based on the number of uploads (attachments).

Community
  • 1
  • 1
Mark Feltner
  • 2,041
  • 1
  • 12
  • 23
  • thanks a lot, this was the missing link to me. Maybe you can add it to your examples for others to find ;-) – dothebart Jan 26 '14 at 16:16
  • @dothebart All of the demos on the homepage include this syntax, as well as the jQuery-specific syntax for registering event handlers. Also, the getting started guide in the documentation is another place that uses this syntax. We can add a note on the events page as well though. – Ray Nicholus Jan 26 '14 at 23:10