|
|
$('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;
|
|
};
|