1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Circuits Select2 forms

This commit is contained in:
John Anderson
2019-01-10 17:50:06 -05:00
parent 60224be272
commit 5f1f8ee73b
2 changed files with 62 additions and 55 deletions

View File

@@ -20,32 +20,3 @@
</div>
</div>
{% endblock %}
{% block javascript %}
<script type="text/javascript">
$(document).ready(function() {
var cluster_group_list = $('#id_cluster_group');
var cluster_list = $('#id_cluster_id');
// Update cluster options based on selected group
cluster_group_list.change(function() {
var selected_groups = $(this).val();
if (selected_groups) {
cluster_list.empty();
$.ajax({
url: netbox_api_path + 'virtualization/clusters/?limit=500&group=' + selected_groups.join('&group='),
dataType: 'json',
success: function (response, status) {
$.each(response["results"], function (index, cluster) {
var option = $("<option></option>").attr("value", cluster.id).text(cluster.name);
cluster_list.append(option);
});
}
});
}
});
});
</script>
{% endblock %}