0

I would like to show list of attachements in my flat view of discussion board in SP2013. Unfortunately i don't have access to SP Designer, so I was trying to use JQuery. But the script from this site, is not working on SP2013. Can anyone help me on this?

EDIT: I am using only first part of the script - without icons! I don't need them.

<script src="/.../Shared%20Documents/jquery-1.11.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        alert("test");
        $('.ms-disc-padabove img[src*="attach.gif"]').each(function(index) {
            alert("test2");
            var divAttachments;
            var displayPageURL = $(this).parents().eq(2).next().find('a')[0].href;
            displayPageURL += " #idAttachmentsTable";
            if (index == 0) {
                divAttachments = "<br/><div id='divAttachments" + index + "'></div>";
                $($($($(this).parents('.ms-disc-padabove')[0]).parent().next()[0]).find('div')[1]).append($(divAttachments));
            } else {
                divAttachments = "<br/><div id='divAttachments" + index + "'></div>";
                $($($($(this).parents('.ms-disc-padabove')[0]).parent().next()[0]).find('div')[0]).append($(divAttachments));
            }
            $("#divAttachments" + index).load(displayPageURL);
        });
    });
</script>
  • Did you download a copy of the jQuery library used in the script and store it in the default library called "Documents"? That's what this line does. <script type="text/javascript" src="../../Shared Documents/jquery-1.4.2.js"></script> – Christoffer Oct 24 '17 at 8:16
  • Yes, I did. And it is loaded. Just to see where is the problem I've added two alerts. But I can see "test" message but not "test2" – sqrhd Oct 25 '17 at 8:17
  • If it does not fire the second alert, then the script can't find the element. try to see if it triggers if you only have $('.ms-disc-padabove'). – Christoffer Oct 25 '17 at 11:21
0

Please use the this version of jQuery - jquery-1.11.2.min

The one mentioned in the site you provided uses version 1.4.2. You can download the latest version from here

Cheers!

  • Unfortunately this didn't change anything and it is still not working...:( – sqrhd Oct 25 '17 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.