WIP javascript app

This commit is contained in:
John Woodlock
2012-06-28 17:01:32 +10:00
parent 0caca699d9
commit 3969ef134d
+22 -10
View File
@@ -15,7 +15,7 @@ formErrorFunction = function(jqXHR, textStatus, errorThrown) {
}; };
function executeAjaxRequest(url, verbType, jsonData, basicAuthKey, successFunction, errorFunction) { function executeAjaxRequest(url, verbType, jsonData, basicAuthKey, successFunction, errorFunction) {
alert("in exAjax");
var jqxhr = $.ajax({ var jqxhr = $.ajax({
url : url, url : url,
type : verbType, //POST, GET, PUT or DELETE type : verbType, //POST, GET, PUT or DELETE
@@ -438,7 +438,7 @@ function showILClient(baseApiUrl, clientId) {
var clientUrl = baseApiUrl + 'clients/' + clientId var clientUrl = baseApiUrl + 'clients/' + clientId
setClientContent("content"); setClientContent("content");
var tab_counter = 1; var tab_counter = 1;
var $newtabs = $("#newtabs").tabs({ $newtabs = $("#newtabs").tabs({
"add": function( event, ui ) { "add": function( event, ui ) {
$newtabs.tabs('select', '#' + ui.panel.id); $newtabs.tabs('select', '#' + ui.panel.id);
@@ -814,7 +814,6 @@ alert("currentTabIndex: " + currentTabIndex );
$("#inputarea").html(formHtml); $("#inputarea").html(formHtml);
alert("repop: " + clientId);
$('#productId').change(function() { $('#productId').change(function() {
var productId = $('#productId').val(); var productId = $('#productId').val();
repopulateFullForm(clientId, productId); repopulateFullForm(clientId, productId);
@@ -878,14 +877,13 @@ alert("currentTabIndex: " + currentTabIndex );
}); });
$('#submitloanapp').button().click(function(e) { $('#submitloanapp').button().click(function(e) {
submitLoanApplication(); submitLoanApplication(clientId);
e.preventDefault(); e.preventDefault();
}); });
$('button#submitloanapp span').text(jQuery.i18n.prop('dialog.button.submit')); $('button#submitloanapp span').text(jQuery.i18n.prop('dialog.button.submit'));
$('#cancelloanapp').button().click(function(e) { $('#cancelloanapp').button().click(function(e) {
var url = '${rootContext}portfolio/client/' + clientId; showILClient(baseApiUrl, clientId);
window.location.href = url;
e.preventDefault(); e.preventDefault();
}); });
$('button#cancelloanapp span').text(jQuery.i18n.prop('dialog.button.cancel')); $('button#cancelloanapp span').text(jQuery.i18n.prop('dialog.button.cancel'));
@@ -925,12 +923,26 @@ alert("currentTabIndex: " + currentTabIndex );
removeErrors("#formerrors"); removeErrors("#formerrors");
var loanScheduleHtml = $("#newLoanScheduleTemplate").render(data); var loanScheduleHtml = $("#newLoanScheduleTemplate").render(data);
$("#schedulearea").html(loanScheduleHtml); $("#schedulearea").html(loanScheduleHtml);
} };
var errorFunction = (function(jqXHR, textStatus, errorThrown) { var errorFunction = function(jqXHR, textStatus, errorThrown) {
$("#schedulearea").html(""); $("#schedulearea").html("");
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors"); handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}); };
executeAjaxRequest(baseApiUrl + 'loans?command=calculateLoanSchedule', "POST", newFormData, base64, successFunction, errorFunction); executeAjaxRequest(baseApiUrl + 'loans?command=calculateLoanSchedule', "POST", newFormData, base64, successFunction, errorFunction);
} }
function submitLoanApplication(clientId) {
var newFormData = JSON.stringify($('#entityform').serializeObject());
var successFunction = function(data, textStatus, jqXHR) {
showILClient(baseApiUrl, clientId);
};
executeAjaxRequest(baseApiUrl + 'loans', "POST", newFormData, base64, successFunction, formErrorFunction);
}