Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoDiscover configuration ignored #15

Open
xenogenesi opened this issue Feb 2, 2018 · 6 comments
Open

AutoDiscover configuration ignored #15

xenogenesi opened this issue Feb 2, 2018 · 6 comments

Comments

@xenogenesi
Copy link

I'm using Chromium (Chrome) and I've a couple of errors in the javascript console:

Uncaught Error: No URL provided.
Uncaught Error: Dropzone already attached.

registerJs() by default bind/wrap its code to the onready event (using jQuery) and this addon use it to configure the AutoDiscover option to true or false.

asset::register() doesn't bind/wrap to anything, as it should be for any javascript library/module, it is included at the end of the body after its dependencies and executed as soon as possible.

The problem is that DropZone, at least the version used by this addon, execute as soon as possible a contentLoaded function that seems to bind to the onload event, when the content is loaded the autoDiscover start.

So what is happening (at least on the Chromium I'm using) is that the DropZone's autoDiscover function is executed before the addon javascript set the autoDiscover configuration.

Currently the only solution I've found is to add a new asset, with the js code to disable the autoDiscover, add to it DropZoneAsset as dependency, and in DropZone.php register it instead, but is far from optimal.

@gabriele-carbonai
Copy link

I solved.
Go to vendor/perminder-klair/dropzone/assets/DropZoneAssets.php
change

public $js = [
        "dropzone/dist/min/dropzone.min.js"
    ];

to

public $js = [
        "dropzone/dist/dropzone.js"
    ];

now open dropzone.js and change
Dropzone.autoDiscover = true;
to
Dropzone.autoDiscover = false;

@tang05709
Copy link

感谢楼上大神的回答,解决了我的问题,另一种方式可以修改dropzone/dist/dropzone.js的Dropzone.autoDiscover = false, 然后使用压缩工具压缩并覆盖"dropzone/dist/min/dropzone.min.js"

mrstroz added a commit to mrstroz/yii2-dropzone that referenced this issue Dec 10, 2018
@mrstroz
Copy link

mrstroz commented Dec 10, 2018

Problem has been solved in my last pull request.

@perminder-klair Please check it and merge

@xenogenesi
Copy link
Author

@mrstroz thanks, I can't test it right now but is looking good (much better/simple than my workaround). I'll give it a try as soon as I get some spare time

@whizsid
Copy link

whizsid commented Dec 19, 2018

@xenogenesi Can you merge this PR?

@xenogenesi
Copy link
Author

@whizsid nope sorry, @perminder-klair should do it, but you can clone @mrstroz 's repository meanwhile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants