SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question came from following up on an answer given here.

I want to use jQuery to work css modifications on a list that has grouping. I discovered a jQuery script called aop.js that will allow you to attach function calls onto other functions. There is another page here with more explanation. And so, I came up with this, where I attach a function call onto ExpGroupRenderData so that I can run a function AFTER the list items are grouped.

jQuery.aop.around( {target: window, method: 'ExpGroupRenderData'},
    function (invocation) {
    //alert("args2=" + invocation.arguments[2] ");
        if (invocation.arguments[2] == 'true') { //check to see if html loaded
            var group = "#tbod"+invocation.arguments[1]+"_";    //the invocation gets the main groupname, something like tbod40-2_, but we add a "_" for the one we are searching for
            var maindiv = jQuery('#pagebody').get(0);               
  , "group", group); //write data to div
        return invocation.proceed();

jQuery.aop.after( {target: window, method: 'ExpGroupRenderData'}, 
    function(result) { 
        var maindiv = jQuery('#pagebody').get(0);
        var group =, "group");
            alert("found group" );
  , "group", ""); //clear out data
        return result;


...snip snip...

Using the code from this page, if I remove the if (invocation.arguments[2] == 'true') test, the function will, indeed, fire, but it only runs on a group that has already been expanded at least once. (Now the styling works fine; I have a post on this here).

_(just a note - you could use any div to store the jquery data property. #pagebody is in my custom master page. I couldn't find a #MSO_ContentTable in my outputted code; but it stores the data just fine)_

The effect is that when the user expands a group, it does not get styled. But if he expands a second group, the previous group gets styled, even if that group has been contracted.

If I leave the if clause, nothing ever happens. If I uncomment the alert in the around function, then I can see that the invocation.arguments[2] (which is the isLoaded property of the ExpGroupRenderData function) is always false when the around function checks it.

It seems like the aop.around function does not wait long enough to check the value of isLoaded.

I have been stuck on this for days. Can anyone make a suggestion?


This seems to work a little bit better. At least it works now on the just-opened group if I open it, close it, and open it again. That is one bit better, at least.

jQuery.aop.after( {target: window, method: 'ExpCollGroup'}, //notice the method
    function() { 
share|improve this question
@Colin - I hope you haven't forgotten me from… ! – bgmCoder Dec 18 '12 at 21:11
Methinks that nobody else uses aop.js, at least, not with Sharepoint. – bgmCoder Dec 29 '12 at 16:20
up vote 1 down vote accepted

Okay, after much hassle and striving, I came up with this which seems to work pretty well, although I hate to use such a mechanism:

$jq.aop.around( {target: window, method: 'ExpGroupRenderData'},
    function (invocation) {

I needed to wait just a wee bit on the aop.around function. Turns out that I don't even need the aop.after if I do it this way. The user sees the syling take effect, however.

share|improve this answer
If noone has a better answer, I'm going to mark my thread solved by me. – bgmCoder Apr 2 '13 at 16:35

Your Answer


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.