0

this question was posted several times and i looked at many solutions.

My Problem:

I want to execute setAccordionActiv(false) after the DOM is loaded.

function setAccordionActiv(paramActiv) {
    if(paramActiv) {
        $(".aui-toggler-content-wrapper").show();
    } else {
        $(".aui-toggler-content-wrapper").hide();
    }
} 

aui-toggler-content-wrapper is part of AUI which is used in Liferay.

I tried using:

Another document ready() because they should be executed serialized

Answers from this Question: forcing a jQuery ready block to run after all other ready blocks

Those are the answers in most Questions.

However none worked for me.

On the contrary alert() did work so aui-toggler-content-wrapper must be the reason.

If i execute setAccordionActiv(false) later for example via button click it does work.

Any help is appreciated.

Community
  • 1
  • 1
Wandang
  • 912
  • 2
  • 8
  • 37
  • Just wrap your function call inside $(document).ready. That should work. – MD Sayem Ahmed Nov 20 '13 at 11:22
  • so your problem is the .aui-toggler-content-wrapper doesnt exist of document ready? – Alex Nov 20 '13 at 11:32
  • yeah, kinda. but the program does not crash (nullpointer) and instead jumps over that command. at least it looks like it. maybe i should rephrase my prob. – Wandang Nov 20 '13 at 11:40

2 Answers2

2
$(document).ready(function(){
setAccordionActiv(false);
   ///////call function with ^^^parameter


 });
    function setAccordionActiv(paramActiv) {
        if(paramActiv) {
            $(".aui-toggler-content-wrapper").show();
        } else {
            $(".aui-toggler-content-wrapper").hide();
        }
    } 

reference .ready()

Rituraj ratan
  • 10,260
  • 8
  • 34
  • 55
0
$(document).ready(function () {
    function setAccordionActiv(paramActiv) {
        if (paramActiv) {
            $(".aui-toggler-content-wrapper").show();
        } else {
            $(".aui-toggler-content-wrapper").hide();
        }
    }
    setAccordionActiv(paramActiv);
}

Read DOM ready

Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107