Hello everyone,
I customized a SharePoint list form using InfoPath, and I added a CEWP to run some JQuery code. The code runs fine, but the problem is that the InfoPath form performs some partial postback, and this breaks the script.
Does anybody know if there's a way I can keep that code alive, or running, every time the form performs a postback?
Here's my code:
<script language="javascript" src="/reqs/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script> <script language="javascript" src="/reqs/Scripts/jquery.SPServices-0.7.1a.min.js" type="text/javascript"></script> <script language="javascript" src="/reqs/Scripts/jquery-ui-1.8.22.custom.min.js" type="text/javascript"></script> <link href="/reqs/Scripts/jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css"/> <script language="javascript" type="text/javascript"> //Wait ##### seconds for form to load before calling the function. window.onload = function(){ window.setTimeout(readyCall, 1000); } function readyCall(){ //Variable for Array where Title column values will be pushed to. var Requestors = []; //Variable for the Requestor Text Field. var RequestorField = "input[id$='FormControl0_V1_I1_T2']" //Call the SPServices library. $().SPServices({ operation: "GetListItems", listName: "Requestor", CAMLViewFields: "", async: false, completefunc: function (xData, Status){ $(xData.responseXML).SPFilterNode("z:row").each(function(){ Requestors.push($(this).attr("ows_Title")); }); } }); $(RequestorField).autocomplete({ source: Requestors, minLength: 2, focus: function(event, ui){ $(RequestorField).val(ui.item.value); return false; } }); } </script>