I have a Confirm mixin that works fine until I put it in a zone. It still pops 
up a confirmation dialog but when Cancel is pressed the mixin fails to stop the 
event.

My mixin adds javascript that observes the element, but the zone seems to upset 
it by adding javascript directly to the element, eg: 

        <a id="eventlink" onclick="javascript:Tapestry.waitForPage(event);" 
shape="rect" href="./simplewithzone:delete">Delete...</a>

What do I need to change in Confirm to make it stop the event when there's a 
zone?

Here's source for confirm.js and Confirm.java:

        var Confirm = Class.create();
        Confirm.prototype = {
                        
                initialize: function(elementId, message) {
                        this.message = message;
                        Event.observe($(elementId), 'click', 
this.doConfirm.bindAsEventListener(this));
                },
                
                doConfirm: function(e) {
                        if (! confirm(this.message)) {
                                e.stop();
                        }
                }
                
        }

        package jumpstart.web.mixins;
        
        import org.apache.tapestry5.BindingConstants;
        import org.apache.tapestry5.ClientElement;
        import org.apache.tapestry5.RenderSupport;
        import org.apache.tapestry5.annotations.AfterRender;
        import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
        import org.apache.tapestry5.annotations.InjectContainer;
        import org.apache.tapestry5.annotations.Parameter;
        import org.apache.tapestry5.ioc.annotations.Inject;
        
        @IncludeJavaScriptLibrary("confirm.js")
        public class Confirm {
        
                @Parameter(value = "Are you sure?", defaultPrefix = 
BindingConstants.LITERAL)
                private String message;
        
                @Inject
                private RenderSupport renderSupport;
        
                @InjectContainer
                private ClientElement element;
        
                @AfterRender
                public void afterRender() {
                        renderSupport.addScript(String.format("new 
Confirm('%s', '%s');", element.getClientId(), message));
                }
        
        }
        
Thanks in advance,

Geoff

Reply via email to