问题
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