I am new to this community and I have been looking for an answer on this for the past 48hs searching and trying.
I created a form in Infopath Designer 2013. Also I am using SPD 2013 and what I am trying to accomplish is to get a couple fields bind to Jquery Autocomplete using SPServices to create the data vector.
I got this to work, but it works only ONCE. I created a page within Sharepoint and included the Infopath Webpart, also a Content Editor Web part with a script snippet that contains:
<script type="text/javascript" src="../jquery-ui-1.11.4.custom/external/jquery/jquery.js"></script>
<script type="text/javascript" src="../jquery-ui-1.11.4.custom/jquery-ui.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery.SPServices.js"></script>
<script type="text/javascript" src="../Scripts/OpenCaseFormAutocomplete.js"></script>
My file script OpenCaseFormAutocomplete:
Sys.Application.add_load(function() {
$(document).ready(readyCall);
function readyCall(){
var externalParties1 = [];
var externalParties2 = [];
$().SPServices({
operation: "GetListItems",
listName: "Autocomplete_Customer",
CAMLViewFields: "",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
externalParties1.push($(this).attr("ows_Title"));
});
}
});
$().SPServices({
operation: "GetListItems",
listName: "Autocomplete_End-User",
CAMLViewFields: "",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
externalParties2.push($(this).attr("ows_Title"));
});
}
});
$("input[id$='FormControl0_V1_I1_T3']").autocomplete({
source: externalParties1,
minLength: 3
});
$("input[id$='FormControl0_V1_I1_T4']").autocomplete({
source: externalParties2,
minLength: 3
});
}
});
/*
I read somewhere that there is an issue with postback. But I don't seem to get this code to work after the first time. The second the form runs a postback call it clears the attached autocomplete from the inputs.
Is there a fix for this, a place I should put the code to avoid loosing the bind or a rebind code alternative?
$("input[id$='FormControl0_V1_I1_T3']").autocomplete
code inside thecompleteFunc
of$().SPServices
has last line ? – Max