How to replicate .sortable and serialize but with Dragula JS?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 13:37:24

问题


I'm trying to understand how to replicate this code:

$(this).on('submit', '#form', function(event) {
    var input = $("<input>")
        .attr("type", "hidden")
        .attr("name", "token_used")
        .val($('#right1').sortable('serialize'));
    console.log($('#right1').sortable('serialize'));
    $('#form').append($(input));
});

to be used with Dragula JS https://github.com/bevacqua/dragula (in vanilla Java Script) instead. I dont understand how to use dragulaJS for the call .sortable and then serialize.

Any suggestion so I can get rid of the .sortable and get the serialize to work all with purse Java Script?

(see reference here for the second part dragula JS: dragula JS move from one list to another with on click event)

My HTML:

<form enctype="" action="" method="post" id="form">
<fieldset>

<input type="text" class="inputfield" value="" id="subject" name="subject">

    <div class="wrapper panel panel-body">
    <ul id="left1" class="cont-dragula">

    </ul>
    <ul id="right1" class="cont-dragula">
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3.</li>
        <li>Item 4.</li>
        <li>Item 5.</li>
        <li>Item 6.</li>
    </ul>
    </div>
</fieldset>
</form>

来源:https://stackoverflow.com/questions/35676922/how-to-replicate-sortable-and-serialize-but-with-dragula-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!