建立client lib,該庫將包含用於在由CSS類savebutton標識的按鈕的點擊事件上調用guideBridge
API方法doAjaxSubmitWithFileAttachment
的代碼。 我們會將最適化表單資料fileMap
和mobileNumber
傳遞至**/bin/storeafdatawithattachments
的端點監聽
保存表單資料後,將生成唯一的應用程式ID,並在對話框中向用戶顯示。 關閉對話方塊時,會將使用者視為表單,讓他們使用唯一的應用程式ID擷取儲存的最適化表單。
$(document).ready(function () {
$(".savebutton").click(function () {
var tel = guideBridge.resolveNode(
"guide[0].guide1[0].guideRootPanel[0].contactInformation[0].basicContact[0].telephoneNumber[0]"
);
var telephoneNumber = tel.value;
guideBridge.getFormDataString({
success: function (data) {
var map = guideBridge._getFileAttachmentMapForSubmit();
guideBridge.doAjaxSubmitWithFileAttachment(
"/bin/storeafdatawithattachments",
{
data: data.data,
fileMap: map,
mobileNumber: telephoneNumber,
},
{
success: function (x) {
bootbox.alert(
"This is your reference number.<br>" +
x.data.path +
" <br>You will need this to retrieve your application",
function () {
console.log(
"This was logged in the callback! After the ok button was pressed"
);
window.location.href =
"http://localhost:4502/content/dam/formsanddocuments/myaccountform/jcr:content?wcmmode=disabled";
}
);
console.log(x.data.path);
},
},
guideBridge._getFileAttachmentsList()
);
},
});
});
});
我們已使用bootbox javascript庫來顯示對話框
此示例中使用的客戶端庫可以從此處下載