I have a small script that customises certain list views, hiding buttons.

This is done using jQuery $(document).ready()

Because this js is manipulating standard pages it is stored in the left sidebar.

However, I can see that the call to the function is being made when the document is not really ready. I'm guessing that salesforce is fetching list contents (including buttons) dynamically.

So my attempts to show or hide something are in vain because that thing has not yet been inserted into the page.

How can I make sure that this script get executed when salesforce is done rendering the list completely?

  • 1
    What list are your referring to exactly? Can you provide more specific details and maybe some sample code?
    – fehays
    Aug 6, 2014 at 15:19
  • It's the standard list view page (aka one of the search layouts) for a custom object.
    – powlo
    Aug 7, 2014 at 16:04

1 Answer 1


Presumably you are aware that Salesforce is making this sort of code harder to add - see End of javascript sidebar hacks?.

If you can detect (e.g. by the presence of an element of a certain class) when the rendering is done, then you can poll for that using JavaScript's setTimeout:

function checkIfThere() {
    // Check for the element and do whatever you need to if you find it
    var foundIt = ...;
    if (!foundIt) {
        // Do the check again in 500 ms
        setTimeout(checkIfThere, 500);
    } else {
        // All done
// Call directly to start it

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .