Author: gseitz Date: Sat Oct 6 14:43:37 2007 New Revision: 582535 URL: http://svn.apache.org/viewvc?rev=582535&view=rev Log: when in AjaxRequest, remove the previously generated markup (see onRendered) via javascript to not render multiple yui calendars
Modified: wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java Modified: wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java?rev=582535&r1=582534&r2=582535&view=diff ============================================================================== --- wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java (original) +++ wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java Sat Oct 6 14:43:37 2007 @@ -35,6 +35,7 @@ import org.apache.wicket.Response; import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.ajax.AjaxEventBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.behavior.AbstractBehavior; import org.apache.wicket.behavior.StringHeaderContributor; import org.apache.wicket.datetime.markup.html.form.DateTextField; @@ -255,6 +256,18 @@ TextTemplate datePickerJs = new PackagedTextTemplate(DatePicker.class, "DatePicker.js"); datePickerJs.interpolate(variables); response.renderOnDomReadyJavascript(datePickerJs.asString()); + + // remove previously generated markup (see onRendered) via javascript in + // ajax requests to not render the yui calendar multiple times + if (AjaxRequestTarget.get() != null) + { + final String javascript = "var e = Wicket.$('" + getEscapedComponentMarkupId() + "Dp" + + "'); if (e != null && typeof(e.parentNode) != 'undefined' && " + + "typeof(e.parentNode.parentNode != 'undefined')) " + + "e.parentNode.parentNode.removeChild(e.parentNode);"; + + response.renderJavascript(javascript, null); + } } /**