0

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!");});
2
  • 1
    You need to add more info into your question. What are those two components ? Is it a JavaScript related question? You should add a tag for that. Could you provide some code and further information about your question? May 12, 2015 at 5:27
  • @DiogoMartins You have been right, in the end it was a JavaScript related question.
    – Rockbot
    May 13, 2015 at 10:54

2 Answers 2

1

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 #

1
  • What do you mean by "answer"?
    – Rockbot
    May 12, 2015 at 9:15
0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.