weixin_33719619 2018-06-26 07:39 采纳率: 0%
浏览 88

禁用Dropzone页面刷新

I have been searching for a few days and have found multiple solutions how to reload page after upload and so on. My issue is that after an upload the page automatically reloads and I do not want this.

I am not sure what I am missing here but this is a pretty standard setup from dropzone home page.

function initDropzone() {


    var dz = new Dropzone('#fupld', {
        url: 'upload',
        autoProcessQueue: true,
        paramName: 'files',
        autoDiscover:false,
        init: function () {
            this.on('queuecomplete', () => {
            }),
                this.on('success', function (file, response) {
            });
            this.on('error', (file, response) => {
                console.log(response);
            });
        }
    });
}


<form class="fupld" action="@Url.Action("upload")" id="fupld" method="post">
    <div class="dz-message">Upload</div>
    <div class="fallback">
        <input name="file" type="file" multiple />
    </div>
</form>

Everything is done as expected. Files are uploaded, errors are displayed etc.

The only thing that I am trying to work around is the fact that after the successful upload the page refreshes and I don't want this.

My server side always returns Json and there is no redirect anywhere.

I have tried to hook into submit event and call preventDefault along with calling the dropzone disable() after successful upload but the page still refreshes.

Any suggestions would be appreciated.

Note this is using .NET to upload.

  • 写回答

3条回答 默认 最新

  • weixin_33670786 2018-06-26 08:28
    关注

    Have you tried to stopPropagation on the event? together with the preventDefault https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation

    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭