Alexandru Coman
Alexandru Coman

Reputation: 165

MooTools: uncaught TypeError: undefined is not a function

So, I have this function:

<script type="text/javascript">

window.addEvent('domready',function() {
    var togglers = $$('div.toggler');
    if(togglers.length) var gmail = new Fx.Accordion(togglers,$$('div.body'));
    togglers.addEvent('click',function() { this.addClass('read').removeClass('unread'); });
    togglers[0].fireEvent('click'); //first one starts out read
});

</script>

and I have this error in Inspect element -> console:

uncaught TypeError: undefined is not a function

I included this library -> <script src="mootools-core-1.4.5.js"></script>

What am I doing wrong?

Thanks.

Upvotes: 0

Views: 1995

Answers (1)

Sergio
Sergio

Reputation: 28837

You just need to add the More library also. You just added Core. Add the More library after the Core code.

window.addEvent('domready',function() {
    var togglers = $$('div.toggler');
    if(togglers.length) var gmail = new Fx.Accordion(togglers, $$('div.body'));
    togglers.addEvent('click',function() { this.addClass('read').removeClass('unread'); });
    togglers[0].fireEvent('click'); //first one starts out read
});

Example based on your code.

Upvotes: 1

Related Questions