1
I wanted to know if you can put a javascript function after clicking and dragging a div (better still: after "drop" the div). I intend to make a code so that every time I move the div to a table happens an UPDATE (but I can’t imagine how to do).
<div class="drag-container">
<ul class="drag-list">
<li class="drag-column drag-column-on-hold">
<span class="drag-column-header">
<h2>Fazer</h2>
</span>
<div class="drag-options" id="options1"></div>
<ul class="drag-inner-list" id="1">
<li class="drag-item"><a href="" >
Je </a></li><br>
</ul>
</li>
<li class="drag-column drag-column-in-progress">
<span class="drag-column-header">
<h2>Fazendo</h2>
</span>
<div class="drag-options" id="options2"></div>
<ul class="drag-inner-list" id="2">
<li class="drag-item"></li>
<li class="drag-item"></li>
<li class="drag-item"></li>
</ul>
</li>
<li class="drag-column drag-column-approved">
<span class="drag-column-header">
<h2>Feito</h2>
</span>
<div class="drag-options" id="options4"></div>
<ul class="drag-inner-list" id="4">
<li class="drag-item"></li>
<li class="drag-item"></li>
</ul>
</li>
</ul>
</div>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/45226/dragula.min.js'></script>
<script src="js/index.js"></script>
JS
dragula([
document.getElementById('1'),
document.getElementById('2'),
document.getElementById('3'),
document.getElementById('4'),
document.getElementById('5')
])
.on('drag', function(el) {
// add 'is-moving'
el.classList.add('is-moving');
})
.on('dragend', function(el) {
// remove 'is-moving'
el.classList.remove('is-moving');
// add 'is-moved' class por 600ms
window.setTimeout(function() {
el.classList.add('is-moved');
window.setTimeout(function() {
el.classList.remove('is-moved');
}, 600);
}, 100);
});
var createOptions = (function() {
var dragOptions = document.querySelectorAll('.drag-options');
P.S.: I haven’t finished the php and html programming of this page yet (to make it more beautiful and functional)
I think you should ask a concise question, like, just as an example: "I have 2 Ivs, right next to each other. I want to drag the one on the left and drop it on the one on the right. How do I detect that the div I dragged was released in the right div and send information (inform what information you want to send) to the database?"... and show the relevant code of it all, so that people can play the HTML and javascript part.
– Sam
The part of PHP does not matter in this case, because then you do the information sent as you want, is another department.
– Sam
I copied your code and show it to me in the browser: https://i.stack.Imgur.com/Tgyfl.jpg
– Sam
for you to see that it’s complicated, what I have to do with it?
– Sam
I could see here what you want to drag. Just call inside the function
.on('dragend',
what you want to do.– Sam
Oops! So, within the function
.on('dragend', function(el) {
you put any function you want to call after an element has been dragged.– Sam
What information do you want to send to the bank?
– Sam