Hi,

We use
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L1617
because
it is faster than jQuery#replaceWith().
So yes, there is a small period when both the old and the new are in the
DOM.
As Sven asked - please create a quicktart and attach it to a ticket so we
can see whether we will find a solution or we will have to use the slower
way to replace.


On Tue, May 14, 2013 at 4:48 PM, Sven Meier <s...@meiers.net> wrote:

> Create a quickstart and attach it to a Jira issue please.
>
> Sven
>
>
> On 05/14/2013 04:37 PM, Nico wrote:
>
>> Hi
>>
>> I migrated my application from Wicket 1.5.10 to 6.7
>>
>> During testing I recognized that during an ajax update (replacement) of a
>> component, the markup of the component is twice in the HTML markup (the
>> old
>> and the new markup). Thus the execution of javascript inside a component
>> may
>> fail due to the fact, that two components with the same id are present in
>> the HTML markup.
>>
>> EXAMPLE
>>
>>
>> *HTML:*
>> &lt;a wicket:id=&quot;testlink&quot;**&gt;testlink&lt;/a&gt;
>> &lt;div wicket:id=&quot;testbox&quot; style=&quot;width: 100px; height:
>> 100px; border: 1px solid #ccc;&quot;&gt;
>>         &lt;script type=&quot;text/javascript&**quot;&gt;
>>                 alert(&#39;hello&#39;);
>>         &lt;/script&gt;
>> &lt;/div&gt;
>>
>> *JAVA:*
>> final WebMarkupContainer testbox = new WebMarkupContainer("testbox");
>> testbox.setOutputMarkupId(**true);
>> add(testbox);
>>
>> add(new AjaxLink<Void>("testlink") {
>>         private static final long serialVersionUID = 1L;
>>
>>         @Override
>>         public void onClick(AjaxRequestTarget target) {
>>                 target.add(testbox);
>>         }
>> });
>>
>>
>> So while the ajax update is processed the 'testbox' DIV and its javascript
>> are present twice (the old and new DIV). If the javascript is a little
>> more
>> complex and for example changes stuff inside the DIV, the javascript will
>> change stuff in the old instead of the new DIV container.
>>
>> My javascript relies on the fact, that an id should always be present just
>> once.
>>
>> Why is the old DIV not removed first, before the new DIV is appended? Can
>> I
>> change this behavior somehow?
>>
>> Thanks in advance
>> Nico
>>
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.**
>> n4.nabble.com/Component-twice-**in-markup-while-ajax-refresh-**
>> in-Wicket-6-7-migrated-from-1-**5-10-tp4658789.html<http://apache-wicket.1842946.n4.nabble.com/Component-twice-in-markup-while-ajax-refresh-in-Wicket-6-7-migrated-from-1-5-10-tp4658789.html>
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: 
>> users-unsubscribe@wicket.**apache.org<users-unsubscr...@wicket.apache.org>
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org<users-unsubscr...@wicket.apache.org>
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
Wicket Training & Consulting
http://jWeekend.com <http://jweekend.com/>

Reply via email to