0

I am attempting to use some DOM manipulation to change list column names on a list Display view.

However when I use Jquery to create the array I get a null value. My test site has the Dialogs setting at No on the list while the Production site has it set to Yes so I am guessing this is what is causing the issue with $('.ms-standardheader'); returning a null value on the production site when I try it in the console window.

On the test site this works without fail, I get my array, and I can do what I need to do.

When I change the Production site to No dialog and run $('.ms-standardheader') in the console I get my array. Perfect! Just what I want.

So, I am pretty sure I know what the issue is but how do I get around the dialog box so my $('.ms-standardheader'); returns the array it is supposed to return?

Is this some issue related to focus or something?

Thanks.

4
  • Is there any update ? Have you tried to add Jquery in DispForm.aspx using SharePoint Designer as suggested in answer below and did it work ? Commented Feb 9, 2021 at 2:18
  • I guess I should have asked the question differently. I did not add jquery to the DispForm as it was being loaded in the CEWP of said form. Was trying to understand how to get past the issue of the code above failing when the form opened in a dialog box vs. full page. Commented Feb 11, 2021 at 15:14
  • No matter dialogue or Full Page, the key point is to add code into DispForm.aspx, as the field control is in dispFrom.aspx rather than AllItems.aspx. Hopefully, this will help you. In the answer, the way to inject using SharePoint Designer will get past the issue as it will add the code into DispForm directly. Commented Feb 11, 2021 at 16:23
  • When open DispForm.aspx in full page, it will redirect to the DispForm.aspx directly, so code will work. When open in dialogue, the real page is still AllItems.aspx, so adding code won't work as it's added in AllItems.aspx not DispForm.aspx Commented Feb 11, 2021 at 16:26

1 Answer 1

0

Actually the List Display form url will like this:

http://sp/Lists/ListName/DispForm.aspx

This is not the same page as AllItems.aspx, so when launch display form in dialogue,$('.ms-standardheader') will be null as the Jquery code is added in AllItems.aspx rather than DispForm.aspx.

A workaround to inject Jquery into real DispForm.aspx is using SharePoint Designer, open the target list in SharePoint Designer and select DispForm.aspx:

enter image description here

Then add Jquery code under PlaceHolderMain tag:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.