Disabling upload widget does not disable drag and drop functionality

1.9k views Asked by At

I disabled upload widget using the following script but I can still use drag and drop functionality to upload files. Is this a bug or Am i doing something wrong?

<script type="text/javascript">
    $(document).ready(function () {
        $("#files").kendoUpload({
            multiple: false,
            async: {
                saveUrl: save,
                autoUpload: true
            },
            enabled: false
        });
    });
</script>
1

There are 1 answers

0
Lars Höppner On BEST ANSWER

I'd call that a bug - here's how you can fix it until Telerik does (demo):

kendo.ui.Upload.fn.toggle = function(enable) {
    var that = this;
    enable = typeof(enable) === "undefined" ? false : enable;
    this.wrapper.toggleClass("k-state-disabled", !enable);
    this.element.prop("disabled", !enable);

    var dragZone = $(".k-dropzone", that.wrapper);
    if (enable) {
        if (!dragZone.length) {
            this._setupDropZone();
        } else {
            dragZone.on("drop" + that._ns, $.proxy(this._onDrop, this));
        }
    } else {
        dragZone.off("drop" + that._ns);
    }
};

kendo.ui.Upload.fn._supportsDrop = function() {
    var userAgent = this._userAgent().toLowerCase(),
        isChrome = /chrome/.test(userAgent),
        isSafari = !isChrome && /safari/.test(userAgent),
        isWindowsSafari = isSafari && /windows/.test(userAgent);

    return !isWindowsSafari && this._supportsFormData() && (this.options.async.saveUrl) && (this.options.enabled);
}

(add this before you first create your widget)