OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums OroCRM OroCRM – How do I? Questions How to add a "beforeClose" or "close" callback in OroCRM Dialogs?

This topic contains 3 replies, has 2 voices, and was last updated by Hryhorii Hrebiniuk Hryhorii Hrebiniuk 8 months, 3 weeks ago.

  • Creator
    Topic
  • #37429

    spyout98
    Participant

    jQuery UI dialogs has some callbacks like ‘close’ and ‘beforeClose’:

    https://api.jqueryui.com/dialog/#event-close
    https://api.jqueryui.com/dialog/#event-beforeClose

    My PHP render a dialog, like that below:

    How do I define a javascript callback, that shows a ‘alert()’ (for example), when dialog is closed?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #37446
    Hryhorii Hrebiniuk
    Hryhorii Hrebiniuk
    Participant

    Hello @spyout98

    Since, close handler it’s a javascript function, we can not define it over widget declaration in twig, due to definition gets serialized into JSON.

    But you can extend existing dialog widget

    Declare it in requirejs configuration

    And change you action button definition

    #37449

    spyout98
    Participant

    Thanks, this solution worked here! I have one more doubt:

    Every dialog can be closed in two situations:

    * 1 – User cancels or close explicitly
    * 2 – User fill correctly the form and the dialog is automatically closed

    How to I execute a custom code when the user do the situation 2? Sometimes I can execute codes only when User cancel/close explicitly a dialog. Other times I want to execute some code when users fills the form and dialog is automatically closed.

    #37454
    Hryhorii Hrebiniuk
    Hryhorii Hrebiniuk
    Participant

    In the second case, user does not close dialog directly. Users submits form data and if it’s valid, server returns back the command to close the widget.

    So, it is too late of preventing dialog from closing at this stage. The content of dialog is disposed.

    See other methods of DialogWidget and AbstractWidget that you can overload and change logic to suite your needs.

    Probably methods that implement data submit.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No