In my portal, I have a custom list that is using grouping. Now, I want to automatically expand all the groups, so I have mustered this javascript/jQuery function. I use a delaying function to load it after the UI. The function gets called (the first popup works), but the javascript fails (the second popup never fires).

function AutoExpandList(collapsemode){
    alert("function called");
    alert("function completed");

The original idea for the wildcard-path was an accepted solution from here. There is a similar SSE post here, but with no viable solution for Sharepoint 2010, so I came up with this.


The function gets called just fine. For example, depending on the parameter, I get an alert in either instance:

function AutoExpandList(collapsemode){

Which means there is an error in the jQuery somewhere (I'm running jQuery v1.10.2).


Okay, I've figured something out. The jQuery fires just fine in a view where inline editing is not enabled. But for some unknown reason, if inline editing is enabled, the jquery function breaks.

How can I get this to work? Are there any jQuery experts out there?

  • where/how are you setting collapsemode? And how are you calling this function? Jul 26, 2013 at 16:17
  • I have a custom masterpage with a scriptlink element where the javascript file is loaded after the UI has loaded. The first alert fires, but the jquery breaks. I have other UI-altering javascripts that work perfectly.
    – bgmCoder
    Jul 26, 2013 at 16:20
  • 1
    My guess is you either have collapsemode undefined or jQuery is not properly loading, replace your first alert with this: alert("function called with " + collapasemode + " using " + $); if either of those diplays as undefined there's your problem Jul 26, 2013 at 16:35
  • That alert fires, and says, function called with 0 using function (e,t){return new x.fn.init(e,t,r)} - which at least means the jquery is firing. The 0 is the parameter I am specifying in the function call - so that is correct, too.
    – bgmCoder
    Jul 26, 2013 at 16:43

2 Answers 2


Try switching out .click() with .trigger("click") instead.



These are the selectors you can use to select an element for which you only have some part of the src or href.

= exactly equal
!= not equal
^= starts with
$= ends with
*= contains

As we all can see you already use $=. This is correct if it ends with minus.gif. This obviously isn't working. Try deleting the :visible part. This works for me.

  • Nice trick, but the second alert still doesn't fire. Does it fire for you?
    – bgmCoder
    Jul 26, 2013 at 16:33
  • @BGM Check my update.
    – user2536
    Jul 26, 2013 at 16:35
  • Nope. Does does the second alert fire for you? The jquery in my other functions fire just fine, so it's something in this here function that is out of whack. I'm running jQuery v1.10.2
    – bgmCoder
    Jul 26, 2013 at 16:37
  • @BGM Try my latest update. That works for me.
    – user2536
    Jul 26, 2013 at 16:47
  • Well, that doesn't fire either, without the :visible part. What could cause the jQuery lines to fail - is there something else - maybe some change in the jQuery version? I am bewildered here. In my script I've got exactly what we've done here. -AH - I've got a clue - see my edit.
    – bgmCoder
    Jul 26, 2013 at 16:53

Okay, I got it to fire in inline-edit mode, using this function:


Now, remember that in my master page, I have a sharepoint scriptlink element instead of a regular html script element; this lets me specify to load my script after the UI is loaded. However, I still have to use the above line, else the jQuery bombs out if the function is run on a page where the view is set to inline-edit mode.

This is what the end function looks like:

function AutoExpandList(collapsemode){
        if (collapsemode) {
        } else {

Note, however, that the function has no effect on gantt view. But it DOES help out with editing inline-edit view - it keeps the categories from collapsing automatically as you edit them - or, rather, the function runs again and re-opens the categories (if you set collapsemode to 0, that is).

In summary, using the scriptlink to load after the UI wasn't enough. It worked fine for the non-inline-editing view, but the inline-editing view seems to have required the "push" as well. Also, much thanks to Daniel Ziga for pointing out the correction to my jQuery comparitors.

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.