【问题标题】:JQuery Autocomplete Sharepoint 2013 and Infopath, Works Only OnceJQuery Autocomplete Sharepoint 2013 和 Infopath,只工作一次
【发布时间】:2017-05-01 03:34:42
【问题描述】:

我是这个社区的新手,在过去的 48 小时搜索和尝试中,我一直在寻找这个问题的答案。

我在 Infopath Designer 2013 中创建了一个表单。此外,我正在使用 SPD 2013,我想要完成的是使用 SPServices 将几个字段绑定到 Jquery Autocomplete 以创建数据向量。

我得到了这个工作,但它只工作一次。我在 Sharepoint 中创建了一个页面,并包含了 Infopath Webpart,它也是一个内容编辑器 Web 部件,其中包含一个脚本 sn-p,其中包含:

<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>

我的文件脚本 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
  });
	
	      
}	  

});
/*

我在某处读到回发存在问题。但我似乎没有让这段代码在第一次之后工作。表单运行回发调用的第二次,它会从输入中清除附加的自动完成功能。

是否有解决此问题的方法,我应该将代码放置在一个位置以避免丢失绑定或重新绑定代码替代方案?

【问题讨论】:

  • 您是否尝试将$().SPServicescompleteFunc 中的$("input[id$='FormControl0_V1_I1_T3']").autocomplete 代码移动到最后一行?

标签: sharepoint sharepoint-2013 jquery-ui-autocomplete infopath spservices


【解决方案1】:

因为无论您是否执行任何操作,表单都会在后台不断地自动重新加载,因此您需要再次调用您的函数。 因此,在函数中的代码末尾,使用 setTimeout() 方法在 500 毫秒后调用自身。
此外,您应该在有 Sys.Application.add_load 的地方执行此操作:

    Sys.Application.add_load(function() {
 ExecuteOrDelayUntilScriptLoaded(YourFunctionName, "sp.js");
  });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    • 2018-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多