You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
1.2 KiB

$('document').ready(function(){
// Botones
$("#animals").click(function(){
$.get( "/animal", function( data ) {
$( "#body" ).html("<button id='animal-add'>+</button><table id='animals-table'></table>");
$( "#animal-add").click(function(){
$( "#body" ).load( "/templates/animal-form.html" );
})
dataSet = data.data.map(function(item) {
return [item.name, item.inital_level+ " - " + item.level];
});
$('#species-table').DataTable({
data: dataSet,
columns: [
{ title: "Name" },
{ title: "Level" }
]});
});
});
$("#species").click(function(){
$.get( "/species", function( data ) {
$( "#body" ).html("<table id='species-table'></table>");
dataSet = data.data.map(function(item) {
return [item.name, item.description];
});
$('#species-table').DataTable({
data: dataSet,
columns: [
{ title: "Name" },
{ title: "Description" },
]
});
});
});
});
//Funtions
//$('#animal-add-button').click(function() {
function onSubmitAnimal(form){
console.log(222);
JSON.stringify($(form).serializeArray());
console.log( data );
return false;
};