-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dialog visible attr change not triggers any hide events #956
Comments
I have the same problem. The example code from the documentation is buggy. <p-dialog (visible)]="display">
<p-footer>
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<button type="button" pButton icon="fa-close" (click)="display=false" label="No"></button>
<button type="button" pButton icon="fa-check" (click)="display=false" label="Yes"></button>
</div>
</p-footer>
</p-dialog> Setting Instead I had to write custom code that calls the <p-dialog #dialog (visible)]="display">
<p-footer>
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<button type="button" pButton icon="fa-close" (click)="dialog.hide($event)" label="No"></button>
<button type="button" pButton icon="fa-check" (click)="confirm();dialog.hide($event)" label="Yes"></button>
</div>
</p-footer>
</p-dialog> |
@StevenLiekens I think you miss-typo in the |
Bad copy-paste indeed. Example code is taken from here: http://www.primefaces.org/primeng/#/dialog I modified the example to make the important bits stand out. I didn't mean to delete the left bracket. |
I'll try to make it absolutely clear for everyone. Here is the minimal repro for a dialog + event handler for <p-dialog [(visible)]="display" (onAfterHide)="alert('Dialog hidden!')" >
<button (click)="display=false">Close</button>
</p-dialog> The workaround that I found is to forward the button's <p-dialog #dialog [(visible)]="display" (onAfterHide)="alert('Dialog hidden!')" >
<button (click)="dialog.hide($event)">Close</button>
</p-dialog> This code is the only code that behaves as expected. |
Was this ever solved, i still cannot get onAfterHide of onBeforeHide to work |
It seems not, it seems an easy one to fix with |
ok i got it working now just by adding the event |
@StevenLiekens I'm sorry, i didn't read your post thoroughly enough to notice that it works if the event is forwarded to the dialog's hide method, anyways it's weird that we need to do such thing to make it work, what if we call the hide method from code and we don't have any event to pass to it? would it need to create a dummy event only to get this to work? @cagataycivici I still think this issue is still unresolved, i think @StevenLiekens hack is a workaround, not a solution. |
I don't think that passing the click event was necessary to make my example work. I don't remember why I added that. |
Ok so it works if we call the hide method, am i right? what about if we just change the variable, does it still triggers the |
Changing the variable does not trigger the event. |
That's the issue i want fixed, that variable is a binding, an input & output for showing/hiding the dialog, so in theory it should as well trigger such events ( |
Some cleanup is in order to make this work. The logic for showing/hiding the dialog and triggering the events looks like a mess. No wonder it doesn't work. These blocks of code look smelly to me: My first thought is that The The I don't know what the I don't know what |
thanks , if you would have removed in the same effort the lines
my ticket #2310 could have been closed too :) |
Thanks @StevenLiekens!!! |
So i want to bind a callback to
onBeforeHide
, and when closing thep-dialog
with thex
button in the header it triggers the callback, so far all green.The issue comes when i close it programatically by setting the
visible
binding to false, it closes as expected, however the event isn't triggered, that's an issue when you have custom templates with buttons that performs an action and then closes the dialog using the variable binding.In current state my workaround is to call the close function both in the button with click binding, and in the
onBeforeHide
event, in that function i set thevisible
binding tofalse
and then execute some post processing.I know it's redundant to set it to false when using the event binding but at least i don't have duplicated code, however it should in deed trigger the event when the
visible
boolean binding changes to false.The text was updated successfully, but these errors were encountered: