[英]unexpected whole page refresh using p:commandButton
我正在使用下面的代碼刪除p:datatable
的行。 如果在p:commandbutton
標記內使用onclick方法,則刷新整個頁面,否則工作正常。 請給我一些解決方案。
<p:commandButton title="Delete Affiliation" immediate="true" process="@this"
update="affiliationList" alt="Delete Affiliation" icon="ui-icon-trash"
action="#{readAuthorDetailsbean.deleteSelectedAffiliation}" style="width:30px"
onclick="return confirm('Are you sure, Do you want to delete this record?');">
<f:setPropertyActionListener value="#{affiliation}"
target="#{readAuthorDetailsbean.selectedAffilliationListAL}" />
</p:commandButton>
如果您將onclick
屬性改為
if (!confirm('Are you sure, Do you want to delete this record?')) return false;
那么它應該會按預期工作。 它的作用是:
false
並且中止進一步的處理。 如果您只是return confirm('Are you sure?')
並且用戶確定,則返回的true
值會取消PrimeFaces在onclick
屬性末尾添加的return false
(它對ajax起作用),而不是ajax請求,您會看到正常提交后(重新加載頁面)。
return false
取消html元素的默認行為 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.