You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andrew Geery <an...@gmail.com> on 2012/03/30 05:03:03 UTC

AjaxRequestTarget.add(component) not replacing component, but duplicating it

I have a ListMultipleChoice component (Wicket 1.5.4) with a Behavior added
to it to enable the use of the Chosen ( http://harvesthq.github.com/chosen/ )
JS library.  Everything works fine until I attempt to add() the component
to a page in an AjaxRequestTarget.  Rather than replacing the component in
the DOM, the add call creates a duplicate component.  Looking in the DOM, I
end up with multiple divs with the same id.

I'm guessing there is some weird interaction between the Chosen JS library
and the Wicket AJAX library.  Has anyone seen anything like this before?

Thanks
Andrew

Re: AjaxRequestTarget.add(component) not replacing component, but duplicating it

Posted by Andrew Geery <an...@gmail.com>.
You are correct: Chosen was indeed adding additional markup that was
throwing off Wicket's ability to replace the form control.

The workaround was to call jquery,remove to fix/clean up the DOM before
Wicket attempted to replace the tag in the renderOnDomReadyJavaScript
method of the behavior.

The select2 project looks great!  I can't wait to use it.

Thanks
Andrew

On Fri, Mar 30, 2012 at 2:42 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> Check what additional markup if generated by Chosen. It transforms
> <select> to more complex HTML structure.
> Then you'll have more information what should be done to replace the
> whole thing, not just to provide new <select> as what Wicket would do
> by default.
>
> I can also recommend you to take a look at
> http://ivaynberg.github.com/select2 . Soon-ish this will have Wicket
> wrapper component created by the Master (Igor Vaynberg).
>
> On Fri, Mar 30, 2012 at 5:03 AM, Andrew Geery <an...@gmail.com>
> wrote:
> > I have a ListMultipleChoice component (Wicket 1.5.4) with a Behavior
> added
> > to it to enable the use of the Chosen (
> http://harvesthq.github.com/chosen/ )
> > JS library.  Everything works fine until I attempt to add() the component
> > to a page in an AjaxRequestTarget.  Rather than replacing the component
> in
> > the DOM, the add call creates a duplicate component.  Looking in the
> DOM, I
> > end up with multiple divs with the same id.
> >
> > I'm guessing there is some weird interaction between the Chosen JS
> library
> > and the Wicket AJAX library.  Has anyone seen anything like this before?
> >
> > Thanks
> > Andrew
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: AjaxRequestTarget.add(component) not replacing component, but duplicating it

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Check what additional markup if generated by Chosen. It transforms
<select> to more complex HTML structure.
Then you'll have more information what should be done to replace the
whole thing, not just to provide new <select> as what Wicket would do
by default.

I can also recommend you to take a look at
http://ivaynberg.github.com/select2 . Soon-ish this will have Wicket
wrapper component created by the Master (Igor Vaynberg).

On Fri, Mar 30, 2012 at 5:03 AM, Andrew Geery <an...@gmail.com> wrote:
> I have a ListMultipleChoice component (Wicket 1.5.4) with a Behavior added
> to it to enable the use of the Chosen ( http://harvesthq.github.com/chosen/ )
> JS library.  Everything works fine until I attempt to add() the component
> to a page in an AjaxRequestTarget.  Rather than replacing the component in
> the DOM, the add call creates a duplicate component.  Looking in the DOM, I
> end up with multiple divs with the same id.
>
> I'm guessing there is some weird interaction between the Chosen JS library
> and the Wicket AJAX library.  Has anyone seen anything like this before?
>
> Thanks
> Andrew



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org