Maybe this is more of a javascript question than a Kirby one.
I have a field with an extended textarea field. When I drag and drop an image into a textarea, I want to do something. I can’t make the event fire.
var field = $(this);
field.find('textarea').on('change keyup keydown paste', function() {
console.log('changed');
});
Typing in the textarea works fine. Drag in an image does not.
Any ideas? Maybe there are more events needed?
I think that’s because the Panel uses a custom plugin for the drag and drop functionality:
(function($) {
$.fn.sidebar = function() {
return this.each(function() {
var sidebar = $(this);
if(localStorage.getItem('sidebar') == 1) {
sidebar.addClass('sidebar-expanded');
} else {
sidebar.removeClass('sidebar-expanded');
}
sidebar.find('.sidebar-toggle').on('click', function() {
if(sidebar.hasClass('sidebar-expanded')) {
sidebar.removeClass('sidebar-expanded');
localStorage.sidebar = 0;
} else {
This file has been truncated. show original
From line 30, you can see what happens what happens when the user grabs a image and want to drop
it on a textarea. I think you need to call a method from the drag and drop plugin instead of listening for the standard events.
I solved it! There is a drop
event:
var field = $(this);
field.find('textarea').on('change keyup keydown paste drop', function() {
console.log('changed');
});
1 Like