From 3c2d0333e25104322d1b882b366225072ca0781d Mon Sep 17 00:00:00 2001 From: John Woodlock Date: Thu, 28 Jun 2012 12:38:32 +1000 Subject: [PATCH] WIP javascript app --- tempjpwNow/resources/jsrenderExtra.js | 55 ++++++++++++++------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/tempjpwNow/resources/jsrenderExtra.js b/tempjpwNow/resources/jsrenderExtra.js index df913d4dc..cffbd9049 100644 --- a/tempjpwNow/resources/jsrenderExtra.js +++ b/tempjpwNow/resources/jsrenderExtra.js @@ -761,34 +761,37 @@ alert("here"); function refreshNoteWidget(clientUrl) { - var successFunction = function(data, textStatus, jqXHR) { - var noteParent = new Object(); - noteParent.title = jQuery.i18n.prop('widget.notes.heading'); - noteParent.notes = data; - - var tableHtml = $("#noteListViewTemplate").render(noteParent); - $("#clienttabrightpane").html(tableHtml); - - $('.editclientnote').click(function(e) { - var linkId = this.id; - var noteId = linkId.replace("editclientnotelink", ""); - var getAndPutUrl = clientURL + '/notes/' + noteId; - var templateSelector = "#noteFormTemplate"; - var width = 600; - var height = 400; - - var saveSuccessFunction = function(data, textStatus, jqXHR) { - $("#dialog-form").dialog("close"); - refreshNoteWidget(); - } - - popupDialogWithFormView(getAndPutUrl, getAndPutUrl, 'PUT', "dialog.title.edit.note", templateSelector, width, height, saveSuccessFunction); - e.preventDefault(); - }); - }; - + eval(genRefreshNoteWidgetSuccessVar(clientUrl)); executeAjaxRequest(clientUrl + '/notes', 'GET', "", base64, successFunction, formErrorFunction); } + + function genRefreshNoteWidgetSuccessVar(clientUrl) { + + var retVar = 'var successFunction = function(data, textStatus, jqXHR) { ' + + ' var noteParent = new Object();' + + ' noteParent.title = jQuery.i18n.prop("widget.notes.heading");' + + ' noteParent.notes = data;' + + ' var tableHtml = $("#noteListViewTemplate").render(noteParent);' + + ' $("#clienttabrightpane").html(tableHtml);' + + ' $(".editclientnote").click(function(e) { ' + + ' var linkId = this.id;' + + ' var noteId = linkId.replace("editclientnotelink", "");' + + ' var getAndPutUrl = "' + clientUrl + '/notes/" + noteId;' + + ' var templateSelector = "#noteFormTemplate";' + + ' var width = 600;' + + ' var height = 400;' + + ' var saveSuccessFunction = function(data, textStatus, jqXHR) {' + + ' $("#dialog-form").dialog("close");' + + ' refreshNoteWidget();' + + ' };' + + ' popupDialogWithFormView(getAndPutUrl, getAndPutUrl, "PUT", "dialog.title.edit.note", templateSelector, width, height, saveSuccessFunction);' + + ' e.preventDefault();' + + ' });' + + ' };' + alert(retVar); + return retVar; + } + function calculateAnnualPercentageRate() { // alert('calculating interest');