我有:
ListView
Button
WebMarkupContainer
(弹出内容容器)
因此,当我填充 时,我向按钮ListView
添加了一个。AjaxEventBehavior
我也覆盖getAjaxCallDecorator()
,因为我需要从每个按钮调用一个 javascript 函数。因此,在decorateScript
函数中,我使用 覆盖WebMarkupContainer
标记 ID setMarkupId()
,它可以工作。我对 执行相同的操作Button
,并且至少在我调用时有效getMarkupId()
。但是当我转到生成的 HTML 时,它不存在!为什么会这样?
代码如下(它在populateItem
from内部ListView
):
infoBtn.add(new AjaxEventBehavior("onclick") {
@Override
protected void onEvent(AjaxRequestTarget target) {
}
@Override
protected IAjaxCallDecorator getAjaxCallDecorator() {
return new IAjaxCallDecorator() {
@Override
public CharSequence decorateScript(Component component, CharSequence script) {
StringBuilder jsScript = new StringBuilder();
infoPopoverContent.setMarkupId(infoPopoverContent.getMarkupId(true) + String.valueOf(pos));
infoBtn.setOutputMarkupPlaceholderTag(true);
infoBtn.setMarkupId(infoBtn.getMarkupId() + String.valueOf(pos));
jsScript.append("$('#" + infoBtn.getMarkupId() + "').popover({");
jsScript.append("html:true,");
jsScript.append("placement:'bottom',");
jsScript.append("content:function() {");
jsScript.append("return $('#");
jsScript.append(infoPopoverContent.getMarkupId());
jsScript.append("').html();");
jsScript.append("}");
jsScript.append("});");
logger.debug(jsScript.toString());
pos++;
return jsScript;
}
@Override
public CharSequence decorateOnSuccessScript(Component component,
CharSequence script) {
// TODO Auto-generated method stub
return null;
}
@Override
public CharSequence decorateOnFailureScript(Component component,
CharSequence script) {
// TODO Auto-generated method stub
return null;
}
};
}
});