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

Fix API JS to read response.results for new API

This commit is contained in:
Jeremy Stretch
2017-03-20 10:06:25 -04:00
parent 671d53877a
commit 36bbcc8559

View File

@ -1,7 +1,7 @@
$(document).ready(function() {
// "Toggle all" checkbox (table header)
$('#toggle_all').click(function (event) {
$('#toggle_all').click(function() {
$('td input:checkbox[name=pk]').prop('checked', $(this).prop('checked'));
if ($(this).is(':checked')) {
$('#select_all_box').removeClass('hidden');
@ -10,7 +10,7 @@ $(document).ready(function() {
}
});
// Enable hidden buttons when "select all" is checked
$('#select_all').click(function (event) {
$('#select_all').click(function() {
if ($(this).is(':checked')) {
$('#select_all_box').find('button').prop('disabled', '');
} else {
@ -25,7 +25,7 @@ $(document).ready(function() {
});
// Simple "Toggle all" button (panel)
$('button.toggle').click(function (event) {
$('button.toggle').click(function() {
var selected = $(this).attr('selected');
$(this).closest('form').find('input:checkbox[name=pk]').prop('checked', !selected);
$(this).attr('selected', !selected);
@ -55,12 +55,12 @@ $(document).ready(function() {
}
// Bulk edit nullification
$('input:checkbox[name=_nullify]').click(function (event) {
$('input:checkbox[name=_nullify]').click(function() {
$('#id_' + this.value).toggle('disabled');
});
// Set formaction and submit using a link
$('a.formaction').click(function (event) {
$('a.formaction').click(function(event) {
event.preventDefault();
var form = $(this).closest('form');
form.attr('action', $(this).attr('href'));
@ -103,8 +103,8 @@ $(document).ready(function() {
$.ajax({
url: api_url,
dataType: 'json',
success: function (response, status) {
$.each(response, function (index, choice) {
success: function(response, status) {
$.each(response.results, function(index, choice) {
var option = $("<option></option>").attr("value", choice.id).text(choice[display_field]);
if (disabled_indicator && choice[disabled_indicator] && choice.id != initial_value) {
option.attr("disabled", "disabled");