mysterious-toddler-20573
03/05/2021, 5:54 PMjs
var myDropzone = new Dropzone("#my-dropzone");
myDropzone.on("addedfile", function(file) {
htmx.trigger('#my-dropzone', 'dropzone:complete');
});mysterious-toddler-20573
03/05/2021, 5:54 PMmysterious-toddler-20573
03/05/2021, 5:55 PMmysterious-toddler-20573
03/05/2021, 5:55 PMmysterious-toddler-20573
03/05/2021, 5:55 PMmysterious-toddler-20573
03/05/2021, 5:55 PMlittle-librarian-31218
03/05/2021, 5:55 PMmysterious-toddler-20573
03/05/2021, 6:00 PMmost-jelly-15242
03/05/2021, 6:00 PMmysterious-toddler-20573
03/05/2021, 6:01 PMmysterious-toddler-20573
03/05/2021, 6:01 PMmost-jelly-15242
03/05/2021, 6:01 PMmysterious-toddler-20573
03/05/2021, 6:02 PMmost-jelly-15242
03/05/2021, 6:05 PMx-init attribute that allows you to initialize any 3rd party library and reference the current element (component) using $el and you can do it inline.little-librarian-31218
03/05/2021, 6:15 PMphp
Dropzone.options.fileUpload = {
init: function() {
this.on("complete", function(file) {
htmx.trigger('#test', 'complete');
});
}
};little-librarian-31218
03/05/2021, 6:15 PMmysterious-toddler-20573
03/05/2021, 6:29 PMmost-jelly-15242
03/05/2021, 7:18 PMmysterious-toddler-20573
03/05/2021, 7:18 PMclever-carpet-39555
03/06/2021, 4:47 AMsalmon-whale-14625
03/06/2021, 5:14 AMclever-carpet-39555
03/06/2021, 5:15 AMambitious-continent-44511
03/06/2021, 9:02 AMcsrftoken for AJAX requests in intercooler.js was done like:
$(document).on('beforeAjaxSend.ic', function(event, ajaxSetup, elt){
ajaxSetup.beforeSend = function(xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
});
would similar thing for htmx look like this:
document.body.addEventListener('htmx:configRequest', function(evt) {
evt.detail.headers['X-CSRFToken'] = csrftoken;
});
Above is working but I am not sure is it "proper" way to do it. Is it better to use some other event (htmx:xhr:loadend).mysterious-toddler-20573
03/06/2021, 12:36 PMjs
htmx.on('htmx:configRequest'), function(evt) {
evt.detail.headers['X-CSRFToken'] = csrftoken;
}
There is also a django-htmx that is worth looking at: https://github.com/adamchainz/django-htmxglamorous-honey-42686
03/06/2021, 1:04 PMmysterious-toddler-20573
03/06/2021, 1:05 PMglamorous-honey-42686
03/06/2021, 1:05 PMmysterious-toddler-20573
03/06/2021, 1:05 PMmysterious-toddler-20573
03/06/2021, 1:06 PMmysterious-toddler-20573
03/06/2021, 1:06 PM