WIP: CompensationAction using jstree
parent
afb78fa670
commit
62e452c625
@ -0,0 +1,45 @@
|
||||
|
||||
<div id="jstree">
|
||||
</div>
|
||||
|
||||
<input id="jstree-input" name="{{ widget.name }}[]" hidden="hidden"/>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$('#jstree').jstree({
|
||||
'plugins': [
|
||||
'checkbox',
|
||||
],
|
||||
'checkbox': {
|
||||
'whole_node': false,
|
||||
},
|
||||
'core' : {
|
||||
'data' : {
|
||||
'url' : '{{ widget.attrs.url }}',
|
||||
'data' : function (node) {
|
||||
return { 'id' : node.id };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#jstree')
|
||||
.on('deselect_node.jstree', function (e, data) {
|
||||
$(data.selected).each(function (val){
|
||||
console.log(val)
|
||||
console.log(this)
|
||||
$(this).after(
|
||||
"<input name='{{widget.name}}[]' value="+val+"/>"
|
||||
)
|
||||
});
|
||||
//$('#jstree-input').val(data.selected);
|
||||
})
|
||||
.on('select_node.jstree', function (e, data) {
|
||||
$(data.selected).each(function (val){
|
||||
$(this).after(
|
||||
"<input name='{{widget.name}}[]' value="+val+"/>"
|
||||
)
|
||||
});
|
||||
//$('#jstree-input').val(data.selected);
|
||||
})
|
||||
});
|
||||
</script>
|
@ -0,0 +1,9 @@
|
||||
{% load l10n %}
|
||||
|
||||
<ul>
|
||||
{% for code in codes %}
|
||||
<li id="{{code.pk|unlocalize}}" class="{% if code.is_leaf%}jstree-leaf{% else %}jstree-closed{% endif %}">
|
||||
{{code.long_name}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
@ -0,0 +1,2 @@
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
|
Loading…
Reference in New Issue