$(document).ready(function() { if( $("#groupForm").length || $("#editGroupForm").length ) { var groupVarsEditor = CodeMirror.fromTextArea(vars, { lineNumbers: true, mode: "yaml" }); groupVarsEditor.setSize(null, 120); } var groups_table = $("#groups_table").DataTable({ "ajax": function(data, callback, settings) { $.getJSON( $SCRIPT_ROOT + "/network/_retrieve_groups", function(json) { callback(json); }); }, "paging": false, "columns": [ { data: 'name', render: function(data, type, row) { // render funtion to create link to group view page if ( data === null ) { return data; } var url = $SCRIPT_ROOT + "/network/groups/view/" + data; return '<a href="' + url + '">' + data + '</a>'; } }, { data: 'vars', render: function(data, type, row) { if ( data === null ) { return ""; } return '<pre style="white-space: pre-wrap">' + JSON.stringify(data, null, 2) + '</pre>'; } }, { data: 'hosts' } ] }); });