[英]How to self-submit a web2py-component at change-event
我加載了兩個不同的組件(A,B),可以在其中將元素從A拖放到B。
更改拖動目標容器時,是否可以在組件B上觸發“自我提交”並傳遞參數? 提前致謝。
編輯1: 組件是非常簡單的解決方案,A顯示一個列表,其中的元素可以拖動(拖放到B),B開頭是空的。 我想要實現的是,如果將en元素放入B中,則該元素上的信息將傳遞給控制器。
編輯2:同時,當元素被刪除時,我能夠觸發一個事件。 我使用了一個名為Dragula的小型拖放腳本( http://bevacqua.github.io/dragula/)-事件觸發如下:
dragula([document.querySelector(".draggable"),document.querySelector(".drag-target")]).on("drop", function () { console.log("This Works!");});
您可以通過以下方式回答拖動事件:
web2py_component("/app/default/comp_b.load?yourpar=1","comp_b_id");
其中comp_b_id是您的component_b的ID,不包含#
有了Massimilianos提示和這個答案,我想出了以下解決方案:
組件A(拖動開始的地方)現在包含以下腳本:
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.