Hi,

What's the error?
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Feb 17, 10:53 am, marioosh <[email protected]> wrote:
> I have a problem with calling function passed as parameter in class
> definition. I get error when i call fun(). How can i correct this ?
>
> var Slider = Class.create({
>         initialize: function (elContainer) {
>                 this.elContainer = elContainer;
>                 if($(this.elContainer).getStyle('left') == '0px') {
>                         this.minimize(this.doit);
>                 } else {
>                         this.doit();
>                 }
>         },
>
>         minimize: function(fun) {
>                 new Effect.Morph(this.elContainer, {
>                         style: 'left: 940px;',
>                         duration: 0.3,
>                         afterFinish: function() {
>                                 $(this.elContainer).setStyle({
>                                         left: '-940px'
>                                 });
>                                 if(fun != null) {
>                                         fun(); <--- !!!!!!!!! ERROR !!!!!!!!!!
>                                 }
>                         }.bind(this)
>                 });
>         },
>
>         maximize: function() {
>                 $(this.elContainer).show();
>                 new Effect.Morph(this.elContainer, {
>                   style: 'left: 0px;',
>                   duration: 0.5
>                 });
>         },
>
>         doit: function () {
>         }
>
> });
>
> (i pasted in:http://pastie.org/391563 to view better)
>
> By the way - this works fine:
>
> function foo(){
>         alert('foo');}
>
> function bar(fn){
>         if(fn != null) {
>                 fn();
>         } else {
>                 alert('bar');
>         }}
>
> bar(foo); // alerts 'foo'
> bar();  // alerts 'bar'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to