我的jquery正在工作,直到仅在sharepoint中刷新 [英] my jquery is working until refresh only in sharepoint

查看:33
本文介绍了我的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));
    }

这篇关于我的jquery正在工作,直到仅在sharepoint中刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆