0

Is it possible in SharePoint Designer 2013 to find the web part templates and wrap identifier div:s around them so I know what they are?

For example if I have a library web part and want to make them all blue, there seems to be no class that groups them in this way, however if I could wrap a div around the library template then I could achieve this.

1 Answer 1

3

What you could do, is to use for example jQuery. There are elements lower down in the structure that has unique (well unique for all List View Webparts) classes.

Ex.

$('.ms-listviewtable').closest('.ms-webpart-chrome').addClass('tada-listview-webpart')

That code adds the class tada-listview-webpart to the most outer element of a List View Webpart.

By running this code after the rendering of the List View Webpart, you have successfully added a class and thereby can add styling to the webpart by the class name :)

Example of running after load of sp.js:

ExecuteOrDelayUntilScriptLoaded(function(){
    $('.ms-listviewtable').closest('.ms-webpart-chrome').addClass('tada-listview-webpart');
}, 'sp.js');

Not one hundred percent sure that sp.js is the script you need to run after, but you can see the load order in the developer tools of a browser, and try the scripts one by one until it works.

1
  • For example in a Content Editor Webpart, or if you have a custom masterpage, you can add a <script> there. Note that you will need to add jQuery for using my code. Btw, a thanks is usually connected to an upvote ;) Aug 5, 2013 at 14:03

Your Answer

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

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