【问题标题】:SharePoint 2013 Hyperlinks Made Using J Query Stop Working After Filtering使用 JQuery 制作的 SharePoint 2013 超链接在过滤后停止工作
【发布时间】:2021-09-11 02:58:07
【问题描述】:

我找到了帖子:sharepoint with JQuery - stops working when click on column filter,但无法正常工作。

我想在 SharePoint 列表的单元格中将 HTML 显示为超链接。在有人尝试过滤列表之前,我的代码一直有效——元素刷新以在 SharePoint 列表中显示搜索结果,并且链接恢复为 HTML 代码,而不是可点击的链接。

我无权访问母版页或 SharePoint Designer。我唯一的选择是 OOB Web 部件。

这是我正在使用的代码:

<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
    var textholder = "";
    $("td.ms-vb2:contains('<a href=')").each(function() {
        textholder = $(this).text();
        $(this).html(textholder);
    });
})
</script>

我可以添加什么来使代码在刷新时工作?我是一个新手,并且希望将解决方案插入代码中,因为我不知道我会在哪里输入命令。谢谢!

【问题讨论】:

    标签: jquery sharepoint filter hyperlink sharepoint-2013


    【解决方案1】:

    这是我用来解决问题的代码(输入到脚本编辑器 Web 部件中):

    <script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    (function () {
            if (typeof SPClientTemplates === 'undefined')
            return;
            SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
            OnPostRender: [
              function (ctx) { DoStuff(ctx); },
            ]
          });
          })();
    
         function DoStuff(ctx) {
        var textholder = "";
        $("td.ms-vb2:contains('<a href=')").each(function() {
            textholder = $(this).text();
            $(this).html(textholder);
        });     }
      $(document).ready(function(){
           var textholder = "";
        $("td.ms-vb2:contains('<a href=')").each(function() {
            textholder = $(this).text();
            $(this).html(textholder);
        }); });
    </script>
    

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 2010-10-06
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      • 2014-06-20
      • 1970-01-01
      相关资源
      最近更新 更多