Frage

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.

War es hilfreich?

Lösung

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).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top