i´m trying to give an eventhandler to every "a.dlclose" inside "div.do-
dlayer". Everthing works fine except that "this.ltoggle" is undefined
inside "$(this.container).select( 'a.dlclose' ).each(... " !?
Below the stripped down examplecode.
Thanks!


ERROR in Firebug:
 handler is undefined
 [Break on this error] handler.call(element, event);


HTML:
                <div class="do-dlayer" style="border: 1px solid red;">Container
                        <div style="width:100px;height:100px; border: 1px solid
blue;">Preview
                        </div>
                        <div style="width:300px;height:300px; border: 1px solid
green;">Layer<a href="#" class="dlclose">close layer</a>
                        </div>
                </div>

JAVASCRIPT:
        function init_dlayer()
                {
                $$('div.do-dlayer').each( function(el){ new
DynamicLayer( el );  } );
                }

        var DynamicLayer = Class.create({
                        container: 0,
                        preview: 0,
                        layer: 0,
                        initialize: function( el )
                                {
                                this.container = el;
                                var parts               = 
this.container.childElements();
                                this.preview    = parts[0];
                                this.layer              = parts[1];
                                this.ltoggle = this.ltoggle.bind( this );
                                this.preview.observe( 'click',  this.ltoggle );

                                alert( 'DynamicLayer.ltoggle(before):' + 
this.ltoggle );
                                $(this.container).select( 'a.dlclose' ).each(
                                                function(elem)
                                                        {
                                                        alert( 
'DynamicLayer.initialize(close:link)' + this.ltoggle );
                                                        elem.observe( 'click',  
this.ltoggle );
                                                        } );
                                },
                        ltoggle: function( ev )
                                {
                                // do something
                                Event.stop( ev );
                                },
                        });


        document.observe("dom:loaded", function() {
                init_dlayer();
                });

HTML:
                <div class="do-dlayer" style="border: 1px solid red;">
                        <div style="width:100px;height:100px; border: 1px solid
blue;">Preview
                        </div>
                        <div style="width:300px;height:300px; border: 1px solid
green;">Layercontent<a href="#" class="dlclose">close layer</a>
                        </div>
                </div>

-- 
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