简体   繁体   English

如何在小门中隐藏/显示yui.calendar.DatePicker

[英]How to hide / show yui.calendar.DatePicker in wicket

I've run in to a problem I hope you guys can help me with. 我遇到了一个问题,希望你们能帮助我。

I'm using a DateTextField with a DatePicker (from yui.calendar), they are both added to a WebMarkupContainer with OutputMarkupId and OutputMarkupPlaceholderTag set to true. 我正在使用带有DatePicker的DateTextField(来自yui.calendar),它们都被添加到WebMarkupContainer中,并且OutputMarkupId和OutputMarkupPlaceholderTag设置为true。

I want to be able to set the visibility of the container, but when I set it from true to false to true, the datepicker is no longer visible (I'm guessing it has to do with it not beeing mentioned in the HTML(?)) and I have to reload the entire page (and loose the input data) to get the DatePicker visible again. 我希望能够设置容器的可见性,但是当我将容器从true设置为false到true时,datepicker不再可见(我猜想它与HTML(? )),然后我必须重新加载整个页面(并松动输入数据),以使DatePicker再次可见。 There is no problem with the DateTextField. DateTextField没有问题。 Is there any good way to work around this? 有什么好的方法可以解决此问题?

JAVA: JAVA:

invoiceDateFromField = new DateTextField("invoiceDateFromField", new PropertyModel(this, "invoiceDateFrom"), new PatternDateConverter("yyyy-MM-dd", true));
    invoiceDateFromField.setOutputMarkupPlaceholderTag(true);
    invoiceDateFromField.add(new DatePicker());
    containsAllContainer.add(invoiceDateFromField);

AjaxLink onClick: AjaxLink onClick:

containsAllContainer.setVisible(!containsAllContainer.isVisible());
target.add(containsAllContainer);//Edit

I tried to remove the DatePicker from invoiceDateFromField, and then add a new one when the container is set to visible, but this did not seem to work either. 我试图从invoiceDateFromField中删除DatePicker,然后在将容器设置为可见时添加一个新的对象,但这似乎也不起作用。

Thanks! 谢谢!
Olle 奥列

YUI will lose its connection to the DOM element when you set it visible=false in Wicket (because the node is removed from the DOM). 在Wicket中将YUI设置为visible = false时,YUI将失去与DOM元素的连接(因为从DOM中删除了该节点)。 So when you add it back to the page, your instance of YUI calendar no longer has any associated field in the DOM. 因此,当您将其重新添加到页面时,YUI日历的实例在DOM中不再具有任何关联的字段。 You need to be sure to update your reference with a new instance of calendar every time you re-render the DateTextField with Wicket 每次使用Wicket重新呈现DateTextField时,都需要确保使用新的Calendar实例更新引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM