You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Eldred Mullany <el...@easypay.co.za> on 2009/06/29 13:13:02 UTC

Prototype Event.Observe() and Tapestry Blocks

Hi 

 

I have a simple toggle on a default block which is called using
setupRender(), inside that block I have some <a href="#">A link to
toggle()</a> which expands a list below. 

 

 

<div id="login-block">

<div t:id="holder">

        <t:delegate to="current" />

      </div>

</div>

 

 

<t:block t:id="block1">

            <div id="block">

                  <div id="arrow-up"/>

                  <div id="arrow-down" style="display:none"/>

                        <a id="link" href="#">Main Title</a>

                  </div>

            <ul id="toggle-list" style="display:none">

                  <li class="list"><a t:type="pagelink"
t:page="to/page">Link1</a></li> 

            </ul>

</t:block>

<t:block t:id="block2">

            <!- some content---> 

</t:block>

<t:block t:id="block3">

            <!- some content---> 

</t:block>

 

.....

 

Now if another block is delegated, my toggle() method does now work
because I am using  the incorrect observe method ie
(Event.observe(document, 'dom:loaded'). That bit I know is wrong. 

 

Code snippet of Toggle.js

 

Toggle.prototype = {

      initialize :Event.observe(document, 'dom:loaded', function() {

            Event.observe(element, 'click', function(event) {

            element.toggle() //toggle the content 

      )}

    }

  } 

 

 

I don't want to have to create a mixin with a custom event handler to
call this toggle() each time a new block is delegated I ie : 

 

private Block getBlock(String blockId) {

      Block block = resources.findBlock(blockId);

      this.renderSupport.addScript("new Toggle('#%s');", block);  //does
not seem right thing to do?

return block == null ? defaultBlock : block;

    }

 

Is their a listener to initialize the Event.oberve(...) when a new block
is delegated.

 

Thank you

            

> Eldred Mullany   EasyPay - Web Developer

Tel (reception): +27 (21) 680 0100  |  Fax: +27 (21) 686 1400  |
www.easypay.co.za <blocked::http://www.easypay.co.za/>   |

EasyPay (Pty) Ltd, Ground Floor, EasyPay House, 14 Belmont Road, Belmont
Office Park, Rondebosch, 

Cape Town, South Africa, 7700  |  PO Box 58, Rondebosch, Cape Town,
South Africa, 7701