Hi everybody,

Integrating a Jquery tooltip (qtip) went smoothly until I tried to do
an Ajax form submit.
The Wicket Ajax Debug panel shows an "Ajax POST stopped because of
precondition check", so an Ajax response is never sent.

What I'm doing is simply render the text for the tooltip on the same
page in a hidden div, then pointing the content of the tooltip to that
div.

the html:

<wicket:head>
        <script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" 
src="/js/jquery.qtip-1.0.0-rc3.min.js"></script>
</wicket:head>

<wicket:extend>
        <div wicket:id="content" style="display: none;">
                <form wicket:id="form">
                        <input type="submit" wicket:id="clickme" value="click 
me">
                </form>
        </div>
        
        <span wicket:id="tipme">hover over me</span>
</wicket:extend>

the page class:

public class JQueryTestPage extends BasePage {
        public JQueryTestPage() {
                WebMarkupContainer content = new WebMarkupContainer("content");
                add(content);

                Form<Void> form = new Form<Void>("form");
                content.add(form);
                form.add(new AjaxButton("clickme") {
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, 
Form<?> form) {
                                System.out.println("testing");
                        }
                        
                });
                
                WebMarkupContainer qtip = new WebMarkupContainer("tipme");
                add(qtip);
                qtip.add(new QTipBehavior(qtip, content));
        }

}


and finally the QTipBehavior:

public class QTipBehavior extends AbstractBehavior {
        private String componentMarkupId;
        private String contentMarkupId;
        
        public QTipBehavior(Component parent, Component content) {
                contentMarkupId = content.getMarkupId();
                componentMarkupId = parent.getMarkupId();
        }
        
        @Override
        public void renderHead(IHeaderResponse response) {
                String javascript = new StringBuilder()
                        .append("$(function() {")
                        .append("       $('#" + componentMarkupId + "').qtip({")
                        .append("               content: $('#" + 
contentMarkupId + "').html(),")
                        .append("               hide: { fixed: true },")
                        .append("               position: { corner: { target: 
'topRight', tooltip:
'leftTop' } },")
                        .append("       })")
                        .append("});")
                        .toString();
                response.renderOnDomReadyJavascript(javascript);
        }
}


All pretty straightforward.

So my guess is somehow Wicket is not happy about the redirection I
created by not using the rendered button directly.
I've been trying to debug this using Firebug, obviously without success.

Does anybody have any hints how to solve this? Is the approach I'm
taking flawed? Maybe jWicket or wiQuery could help here?



Antoine

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to