Fine Uploaders deleteComplete事件挂钩

时间:2014-01-26 11:12:18

标签: javascript fine-uploader

使用http://fineuploader.com/demos.html并不是那么多js家伙给了我一个很好的开端,让你在城堡网络界面上工作。 我未能实现的最后一个问题是注册了deleteComplete钩子(如下所示:http://docs.fineuploader.com/api/events.html#deleteComplete) 我可能缺少一些特定领域的词汇,所以我的一般问题是,如何指定事件处理程序,deleteComplete是特定的。

我需要调用update_attachment_count(),它应该刷新为主屏幕中编写的邮件上传的附件数量。

到目前为止我已经(我们不使用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,非常感谢您提供Fineuploader。

1 个答案:

答案 0 :(得分:0)

我不清楚你正在尝试使用事件处理程序做什么,但这里是你在上面指定的三个语法的正确语法。

// ...
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);
    }
},
// ...

对于jQuery事件,请参阅FineUploader OnComplete not being called

Need FineUploader Method uploadStoredFiles to Complete Before Proceeding会让您开始根据上传次数(附件)更新用户界面。