I load two different components (A,B), where i can drag and drop elements from A to B.
Is it possible to trigger a "self-submit" on component B and pass arguments when the drag-target container is changed? Thanks in advance.
Edit 1: The components are very simple solutions, A displays a list which elements can be dragged (and dropped to B), B is empty in the beginning. I want to achieve that if en element is dropped into B, informations on the element are passed to the controller.
Edit 2: Meanwhile I am able to trigger an event when the element is dropped. I used a small Drag-and-Drop script called Dragula ( http://bevacqua.github.io/dragula/ ) - the event is triggered like this:
dragula([document.querySelector(".draggable"),document.querySelector(".drag-target")]).on("drop", function () { console.log("This Works!");});
You can answer to your drag event with something like:
web2py_component("/app/default/comp_b.load?yourpar=1","comp_b_id");
where comp_b_id is the id of your component_b without #
With Massimilianos hint and this answer I came up with this solution:
Component A (where the drag starts) now contains this script:
<script>
/* Provides Drag and Drop functionality */
d = dragula([document.querySelector(".drag-start"), document.querySelector(".drag-target")]);
d.on('drop', function(el) {
var test1, test2, id;
test1 = 'test1'; /* Some information */
id = $('.drag-target').attr('id'); /* The target ID */
/* Pass data to the controller */
$.post("{{=URL('controller', 'function')}}"+"/"+test1);
/* Reload data to the target id */
x = web2py_component("/app/controller/function.load"+"/"+id);
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.