Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer
    
Thanks, where would I put it? –  welovedesign Aug 5 '13 at 14:00
    
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 ;) –  Robert Lindgren Aug 5 '13 at 14:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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