我的jquery正在工作,直到仅在sharepoint中刷新
问题描述:
我在sharepoint中有一个jquery脚本,用于插入带有附件的日期.在编辑页面中.仅在刷新编辑页面后才能工作.我该如何解决这个问题?
I have a jquery script in sharepoint to insert a date with attachment. It's in the edit page. It works only after refreshing the edit page. How can I solve this problem?
<script type="text/javascript">
$(document).ready(function () {
SP.SOD.executeFunc("sp.js", 'SP.ClientContext', RenameAttachments);
});
var attfiles;
function RenameAttachments() {
var ctx = new SP.ClientContext.get_current();
attfiles = ctx.get_web().getFolderByServerRelativeUrl('Lists/Test/Attachments/' + getUrlParameter('ID')).get_files();
ctx.load(attfiles);
ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFailed));
}
.........等等
......... etc
答
请找到代码的修改内容.
Please find the modification of the code.
这将在页面加载时运行,并且在我们编辑共享点页面时将起作用.
This will run on the load of the page and it will work when we edit the share-point page.
<script type="text/javascript">
jQuery(window).load(() => {
SP.SOD.loadMultiple(["sp.js", "clienttemplates.js"], RenameAttachments);
});
var attfiles;
function RenameAttachments() {
var ctx = new SP.ClientContext.get_current();
attfiles = ctx.get_web().getFolderByServerRelativeUrl('Lists/Test/Attachments/' + getUrlParameter('ID')).get_files();
ctx.load(attfiles);
ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFailed));
}