I'm customizing the default EditForm.aspx of a list in Sharepoint with Javascript directly on a Script Editor content webpart on the page.
One item that I have customized is the Save Button event.
Fisrt I remove the default event of the Button:
$("[name*='SaveItem']:visible").removeAttr("onclick");
After I use my custom code to save form
$("[name*='SaveItem']:visible").on("click", function(e){
$("#loading").show();
var answer = confirm("Save Item?");
if (answer)
{
if (!PreSaveItem()){
return false;
}
if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')){
return false;
}
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions($("[name*='SaveItem']:visible").attr("id"), "", true, "", document.location.origin, false, true));
}
else{
$("#loading").hide();
}
});
When I try to attach a item, everything seems correct. The file appears in the final of the form.
But when I click to Save, all fields are updated, but the attachment file is not saved in the item.
Note: If I follow the same steps but click on default Save Button on the sharepoint ribbon, the attachmente is saved on item.
Any suggestions to try to solve this problem?