I'd like to use Dropzone.js in application which is built with Backbone and Require.JS, but I have no idea how to implement it.
Should I use require()?
What is the most skillful way to manage it?
Edit:
I've treid to use dropzone-amd-module in on of my backbone view module like this:
define([
'jquery',
'underscore',
'backbone',
'dropzone'
], function($, _, Backbone, Dropzone){
var NewProduct = Backbone.View.extend({
el: $('.products'),
render: function(){
$(this).empty();
require(['text!templates/product_new.html'], function(product_new){
var product_new = _.template(product_new);
$('.products').html(product_new);
});
Dropzone.forElement("#my-awesome-dropzone").on("addedfile", function(file) {
console.log("uploaded");
});
}
});
return NewProduct;
});
Using this HTML in template:
<form action="/upload'" class="dropzone" id="my-awesome-dropzone" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
</form>
But nothing happened.