首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >活线暂时禁用动作

活线暂时禁用动作
EN

Stack Overflow用户
提问于 2022-09-21 14:33:35
回答 2查看 103关注 0票数 0

在其他事情发生的时候,什么是暂时阻止行动的最好方法?

例如一个缓慢的文件上传,阻止操作“存储”被提交。

尝试使用公共财产,但这太慢了。

代码语言:javascript
复制
<form wire:submit.prevent="store" enctype="multipart/form-data">
    <x-forms.filepond wire:model="file_upload" />

    <button wire:click.prevent="store" wire:loading.attr="disabled">
        <x-loader wire:loading wire:target="store" class="full-current mr-2 h-4 w-4" />
        <x-icons.save wire:loading.remove wire:target="store" class="full-current mr-2 h-4 w-4" />
        Save
    </button>
</form>
EN

回答 2

Stack Overflow用户

发布于 2022-09-21 17:33:29

我会尝试高寒或允许商店提交并检查商店功能上的上传。

票数 0
EN

Stack Overflow用户

发布于 2022-12-03 02:27:28

这就是我如何用AlpineJS实现的

飞秒分量,

代码语言:javascript
复制
@props(['key'])
<div
        wire:ignore
        x-data
        x-init="
        () => {
            const pond = FilePond.create(document.getElementById('{{ $key }}'));
            pond.setOptions({
                credits: false,
                disabled: {{ $attributes->has('disabled') ? 'true' : 'false' }},
                allowMultiple: {{ $attributes->has('multiple') ? 'true' : 'false' }},
                server: {
                    process:(fieldName, file, metadata, load, error, progress, abort, transfer, options) => {
                        @this.upload('{{ $key }}', file, load, error, progress)
                    },
                    revert: (filename, load) => {
                        @this.removeUpload('{{ $key }}', filename, load)
                    },
                },
                allowImagePreview: {{ $attributes->has('allowFileTypeValidation') ? 'true' : 'false' }},
                imagePreviewMaxHeight: {{ $attributes->has('imagePreviewMaxHeight') ? $attributes->get('imagePreviewMaxHeight') : '256' }},
                allowFileTypeValidation: {{ $attributes->has('allowFileTypeValidation') ? 'true' : 'false' }},
                acceptedFileTypes: {!! $attributes->get('acceptedFileTypes') ?? 'null' !!},
                allowFileSizeValidation: {{ $attributes->has('allowFileSizeValidation') ? 'true' : 'false' }},
                maxFileSize: {!! $attributes->has('maxFileSize') ? "'".$attributes->get('maxFileSize')."'" : 'null' !!},
                onaddfilestart: function(file) { submitButtonDisabled = true },
                onprocessfiles: function() { submitButtonDisabled = false },
                onupdatefiles: function (files) {
                    fileStatus = true;
                    files.forEach(function (file) {
                        if(file.status != 5) fileStatus = false;
                    });
                    if(fileStatus) submitButtonDisabled = false;
                },
            });
            this.addEventListener('reset-pond', e => {
                pond.removeFiles();
            });
        }
    "
>
    <input type="file" id="{{ $key }}"/>
</div>
<x-inputs.error field="{{ $attributes->has('multiple') ? $key . '.*' : $key }}"/>

(从根本上看onaddfilestartonprocessfilesonupdatefiles filepond事件)

然后在文件上传组件上

将其添加到根目录div x-data="{ submitButtonDisabled: false}"

  • add,将其添加到提交按钮x-bind:disabled="submitButtonDisabled"

中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73802588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档