One convention is to pass onThing events to the options object. However those should be handled by Events, rather than calling directly.
To answer your question, when using Events (I added it to the Implements), just pass the list to the array with arguments the event is called with, like in this jsfiddle: http://jsfiddle.net/36txK/11/ See http://mootools.net/docs/core/Class/Class.Extras#Events:fireEvent Finally another common convention is to add: this.element = document.id(el); (before this.setOptions) to your initialize method. That way you can access the element in your other methods too. When you're using Events, this in the function is the instance context, so you can access the "el" element by this.element as well. On Sat, Dec 29, 2012 at 12:54 PM, Hamburger <[email protected]> wrote: > Hello, > sorry it's me again. > I have seen a class witch is passing an object like this: this.options. > onFail( this.getList() ); to an empty function. > > now I'am trying to get access to the passed element. without success. what > is the trick? > > var validate = new Class({ >> Implements : [ Options ], >> options : { >> validateOnBlur: true, >> onFail: function(){} >> >> }, >> initialize: function(el, options){ >> this.setOptions( options ); >> this.options.onFail( this.getList() ); >> >> >> }, >> >> getList: function(){ >> var liste = new Element('ul'); >> var li = new Element('li').inject(liste); >> return liste; >> } >> >> >> >> }); >> >> >> var myFormValidation = new validate ('test',{ >> onFail: function(){ console.log('how to get the passed list'); } >> }) >> >> > or: > http://jsfiddle.net/36txK/10/ > >
