i'm making an relese access using Nestable List, And when i drop the item from List1 to List2 i have to save on database, so how i identify what item was dropped on List2?
This is my code:
<div class="col-lg-6">
<h3 class="droppTextCenter">Serviços Disponíveis</h3>
<div class="dd" id="nestable">
<script id="template" type="text/template7">
<ol class="dd-list">
{{#each Services}}
<li class="dd-item" data-id="{{Id}}">
<div class="dd-handle">
<div class="col-lg-9">
{{Descryption}}
</div>
</div>
</li>
{{/each}}
</ol>
</script>
</div>
</div>
<div class="col-lg-6">
<h3 class="droppTextCenter">Serviços Liberados para o Usuário</h3>
<div class="dd" id="nestable2">
<script id="template2" type="text/template7">
<ol class="dd-list">
{{#each ServicesReleased}}
<li class="dd-item" data-id="{{Id}}">
<div class="dd-handle">
<div class="col-lg-9">
{{Descryption}}
</div>
</div>
</li>
{{/each}}
</ol>
</script>
</div>
</div>
I'm using template7 to make the List.
So i will make an ajax method on nestable onChange to save it in database.
$('#nestable').nestable({
maxDepth: 1,
group: 1
}).on('change', updateOutput);
// activate Nestable for list 2
$('#nestable2').nestable({
maxDepth: 1,
group: 1
}).on('change', updateOutput);
This one will be the replace for updateOutput
.
When i move it, from List1 to List2 i have to save on database, but when i move from List2 to List1 i have to delete it from database.
function saveServicosLiberados() {
$.ajax({
url: "/Admin/MeusNegociosAcessos/SaveServicosLiberados",
method: "POST",
data: {
Id: ????????
},
success: function (result) {
var list = e.length ? e : $(e.target), output = list.data('output');
if (window.JSON) {
output.val(window.JSON.stringify(list.nestable('serialize')));
} else {
output.val('É necessario estár com um nevegador com suporte à JSON.');
}
}
});
}
function deleteServicosLiberados() {
$.ajax({
url: "/Admin/Delete",
method: "POST",
data: {
Id: ??????????
},
success: function (result) {
var list = e.length ? e : $(e.target), output = list.data('output');
if (window.JSON) {
output.val(window.JSON.stringify(list.nestable('serialize')));
} else {
output.val('É necessario estár com um nevegador com suporte à JSON.');
}
}
});
}
So, how i take the Id from the item dropped?