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 prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---