[solved] "this.setOptions is not a function" error

here you will find only solved 1.1 Help topics

Moderator: 1.1 Moderators

[solved] "this.setOptions is not a function" error

Postby blindMoe on Sun Sep 28, 2008 10:14 pm

For some reason when trying to create a new class I am getting the error "this.setOptions is not a function" I can't figure out what is causing it and have cut the code down to dang near nothing.
Here is the code.. extremely simple:

  1.  
  2. var testclass = new Class({
  3.         Implements: Options,
  4.         options: {
  5.                 container:              null,
  6.                 leftdiv:                null
  7.         },
  8.         initialize: function(options){
  9.                 this.setOptions(options);
  10.         }
  11. });
  12.  


and here is my code to create an instance of the class:

  1.  
  2. window.addEvent('domready', function(){
  3.         var testobject = new testclass({
  4.                 container:      'test1',
  5.                 leftdiv:        'test2'
  6.         });
  7. });
  8.  


Obviously I am missing something that is most likely very simply but for some reason I can't figure it out.. any help would be greatly appreciated.
Last edited by blindMoe on Mon Sep 29, 2008 4:12 pm, edited 2 times in total.
blindMoe
 
Posts: 12
Joined: Sun Sep 28, 2008 10:06 pm

Re: "this.setOptions is not a function" error

Postby blindMoe on Sun Sep 28, 2008 10:16 pm

I forgot to mention that other mootools scripts on the same page work just fine so the mootools library is being loaded properly.
blindMoe
 
Posts: 12
Joined: Sun Sep 28, 2008 10:06 pm

Re: "this.setOptions is not a function" error

Postby xeran on Mon Sep 29, 2008 12:48 am

With Mootools 1.1, you'll need to change the syntax of Implements.

  1.  
  2. var testclass = new Class({
  3.         options: {
  4.                 container:              null,
  5.                 leftdiv:                null
  6.         },
  7.         initialize: function(options){
  8.                 this.setOptions(options);
  9.         }
  10. });
  11. testclass.implement(new Options);
  12.  
xeran
mootools connoisseurs
 
Posts: 27
Joined: Tue Sep 23, 2008 4:35 pm

Re: "this.setOptions is not a function" error

Postby blindMoe on Mon Sep 29, 2008 5:58 am

beautiful, thank you very much for the quick response... a lot of people do not specify whether or not their tutorials are for 1.11 or 1.2 so it can be confusing sometimes when learning :)

thanks again!
blindMoe
blindMoe
 
Posts: 12
Joined: Sun Sep 28, 2008 10:06 pm

Re: "this.setOptions is not a function" error

Postby xeran on Mon Sep 29, 2008 4:10 pm

It's no problem!

Just in case you need this: http://docs111.mootools.net/
xeran
mootools connoisseurs
 
Posts: 27
Joined: Tue Sep 23, 2008 4:35 pm

Re: [solved] "this.setOptions is not a function" error

Postby sensomedia on Wed Mar 04, 2009 9:12 am

... and of course even with mootools 1.2 make SURE to write 'Implements' with capital 'I' ... took me half an hour to find that nasty typo in my code :oops: ...
sensomedia
 
Posts: 2
Joined: Wed Mar 04, 2009 9:08 am


Return to Solutions

Who is online

Users browsing this forum: No registered users and 1 guest