문제

I've just recently started using .

I can't seem to wrap my head around how to properly load and use 3rd party JavaScript libraries.

I am trying to implement a file upload form with the help of some 3rd parties. I want something like DropzoneJS or jQuery Multiple File Upload to handle file selection, while Ink File Picker stores the files in the cloud.

The problem is that the libraries don't react when I try to use them. I can see in the browser that the library gets loaded, and the console is not showing any errors.

Example with DropzoneJS:

JS:

Template.frontpage.rendered = function () {
  $('#dropzone').dropzone({ url: '/file/post' });
}

HTML in the frontpage template:

<form id="dropzone"></form>

This results when inspecting:

<form id="dropzone" class="MultiFile-intercepted dz-clickable"></form>

Something is happening, but the form is not being visually rendered at all.

I place the libs in the /client/libs directory. As some have suggested, I've also tried placing them in /client/compatibility.

I have also tried the Dropzonejs meteorite package with no difference.

What am I doing wrong? How can I make libraries like these function properly in Meteor?

도움이 되었습니까?

해결책

The way to do it is to create smart package and include them in your app.

http://docs.meteor.com/#writingpackages

There are plenty of package examples to follow.

https://atmosphere.meteor.com/

For quick hack, you can also load javascript by creating tag in main.html or call $.getScript(). But this is not recommended as some libraries will have namespace/name conflicts with each other.

다른 팁

Some 3rd party libraries may work out of the box with Meteor, while others may not.

If you actually have an issue with the Dropzonejs meteorite package, then you should file a bug on its GitHub, because meteorie package should work.

For other 3rd party libraries, the issue is usually one of scoping. Check out Packaging Existing Libraries for Meteor for suggestions. Usually what's required are some export statements.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top