open attachment in new form but delte in _self

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
keusch
Posts: 11
Joined: Mon Apr 01, 2019

12 Oct 2021

Hello,
I've adapted the attachments control with the following Java script:

Code: Select all

fd.field('Attachments').control()._el().find('a').removeProp('onclick').prop('target','_blank');
Which works fine for displaying an attachment in a new browser window but it also sets the delete link to target _blank which blocks the delete function - is there a way to only adapt the link of the attachment to be opened in a new window(_blank) and leave the delete link as it originally is?
best regards
Christian

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

13 Oct 2021

Hello keusch,

You can try out this code:

Code: Select all

var attachmentsLink = fd.field('Attachments').control()._el().find('a');

for (var i = 0; i < attachmentsLink.length; i++) {
    
    if(i % 2 === 0){
        $(attachmentsLink[i]).removeProp('onclick').prop('target','_blank');
    }
}

keusch
Posts: 11
Joined: Mon Apr 01, 2019

14 Oct 2021

Thank you works fine.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests