我有一个简单的模态弹出窗口,可以通过按钮关闭。在将要显示模态的页面上,有一个带有id的占位符。当页面首次加载时,我将addOrReplace一个空的Panel。然后,为了响应正确的操作,我将此面板与模态面板交换。然后我关闭面板并再次与另一个空面板交换。一切正常。但这是奇怪的事情 - 当我第二次这样做时,模态面板正常打开,但是当我按下关闭它时它不会关闭,即使它被新的空面板替换并添加到目标 - 但它之前有效!当我再次按下相同的按钮时,一切都崩溃了,无法找到模态标记的组件(但是它应该没有标记了!)
我整天都在想这件事,但我还是没有找到这一切的原因。任何帮助将不胜感激。
private void swapToDummyPopupContainer() {
currentPopupContainer = new DummyPanel("popupContainer");
addOrReplace(currentPopupContainer);
}
private void swapToCreationPopupContainer(final FCalendarEvent event) {
EventCreationPopup popup = new EventCreationPopup("popupContainer", event) {
private static final long serialVersionUID = 965466080498078142L;
@Override
public void onDataSubmit(AjaxRequestTarget target) {
AvailabilityDTO model = getModel();
event.setTitle(model.getDescription());
pushNewEventToModel(model);
availabilityMapping.put(event.getId(), model);
FCalendarEventActions.addEvent(target, fcalendar, event);
swapToDummyPopupContainer();
target.add(currentPopupContainer);
}
@Override
public void onCancel(AjaxRequestTarget target) {
swapToDummyPopupContainer();
target.add(currentPopupContainer);
}
};
currentPopupContainer = popup;
addOrReplace(currentPopupContainer);
}
@Override
protected void onRangeSelection(AjaxRequestTarget target, Date startDate, Date endDate,
boolean isAllDay) {
final FCalendarEvent event = new FCalendarEvent();
swapToCreationPopupContainer(event);
target.add(currentPopupContainer);
}
至于标记
<wicket:container wicket:id="popupContainer" />
父面板中的和要交换的两个面板都是这样定义的
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<wicket:panel>
</wicket:panel>
</html>
在模态标记的末尾(在关闭标记之前)有javascript,但我不相信它与它有任何关系:
<script type="text/javascript">
var $modal = $('#eventCreationPopup');
$modal.modal('setting', {
selector : {
close : '',
approve : '',
deny : ''
}
});
$modal.modal("show");
</script>
答案 0 :(得分:0)
您无法将JavaScript事件附加到
<wicket:container wicket:id="popupContainer" />
因为wicket:容器在Wicket生成的最终标记中没有真正的标记。在这种情况下,setOutputMarkupPlaceholderTag(true)无效。
将其更改为DIV标记:
<div wicket:id="popupContainer"></div>