我正在尝试使用JavaScript在页面加载时打开primefaces对话框组件,但我无法打开它。我的“这里!”页面加载时会触发警报,但不能使用客户端上的widgetvar属性找到该组件。有人知道JavaScript中的正确引用吗?
代码:
<ui:composition template="#{layoutBean.registeredTemplate}">
<ui:define name="head">
<script type="text/javascript">
jQuery(document).ready(function(){
alert("HERE!");
scrapeImagesDlg.show();
});
</script>
</ui:define>
<ui:define name="content">
<p:dialog header="#{bundle['bookmarklet.dialog.HEADER']}"
widgetVar="scrapeImagesDlg"
modal="true"
styleClass="dialog dialog2"
draggable="false"
resizable="false"
showEffect="fade"
hideEffect="fade"
closeListener="#{bookmarklet.close}"
onCloseUpdate="imageGrid">
<div class="dialog dialog2">
<div class="dialog-top-reg"></div>
<div class="dialog-middle-reg">
<div class="close-button"><h:form>
<p:commandButton onclick="scrapeImagesDlg.hide()"/>
</h:form></div>
<h:form id="scrapeFrm">
<p:commandButton onclick="scapeImages()" value="scrape images"/>
<h:inputHidden id="scrapeURL" value="http://www.freefoto.com/preview/04-01-70?ffid=04-01-70"/>
<p:remoteCommand name="scapeImages"
process="@this,scrapeURL"
actionListener="#{bookmarklet.loadImages}"
update="imageGrid"/>
<p:outputPanel id="imageGrid">
<p:dataGrid var="img"
value="#{bookmarkletBean.imageURLs}"
rendered="#{bookmarkletBean.shouldRender}"
columns="1"
rows="1"
paginator="true"
effect="true"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
paginatorPosition="bottom">
<p:column>
<h:panelGrid columns="1" style="width:100%">
<p:graphicImage value="#{img}" width="100" height="100"/>
</h:panelGrid>
</p:column>
</p:dataGrid>
</p:outputPanel>
</h:form>
</div>
<div class="dialog-bottom-reg"></div>
</div>
</p:dialog>
</ui:define>
</ui:composition>
答案 0 :(得分:11)
<p:dialog visible="true" ...>
告诉PrimeFaces在加载页面时自动打开对话框。