[add] Loading views

This commit is contained in:
2018-08-12 11:32:48 -06:00
parent 0ec20a4c67
commit b03d152f11
4 changed files with 94 additions and 7 deletions

View File

@@ -0,0 +1,3 @@
function saveNewEmployee(){
console.log('saving...');
}

View File

@@ -3,7 +3,7 @@
* back to the login form
*/
function logout() {
var baseUrl = getbaseUrl();
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/session/logout',
@@ -28,4 +28,50 @@ function logout() {
}
},
});
}
/**
* Entry point for loading elements from the navatation var, this functuion
* will filter the junk clicks that have landed in a dropdown menu and pass
* only the ones containing an action to the actual view loader
*/
$('#nevatation-options li a').click(function(){
let view = $(this).data('nav_accion');
if (view != "#" && view != undefined) {
loadView(view);
}
});
/**
* Will fetch the html of the desired view and load it into the landing page
*
* @param requestedView string
*/
function loadView(requestedView){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/html/' + requestedView,
type: 'get',
success:function(data){
$("#newViewBody").hide().html(data).show('slow');
},
error:function(x,e) {
if (x.status==0) {
$('#modal_error_internet').modal('show');
} else if(x.status==404) {
$('#modal_error_404').modal('show');
} else if(x.status==500) {
$('#modal_error_500').modal('show');
} else if(e=='parsererror') {
$('#modal_error_parsererror').modal('show');
} else if(e=='timeout'){
$('#modal_error_timeout').modal('show');
} else {
$('#modal_error_otro').modal('show');
}
},
});
}