search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Which java script files and functions are absolutely essential to close a modal form?

Asked by mrplatypus
6 years ago.

Hi Dan and Team,

In two other related postings:

http://forums.daypilot.org/Topic.aspx/3324/is-it-possible-to-display-a-daypilot-modal-dialog-form-from
http://forums.daypilot.org/Topic.aspx/3327/ive-managed-to-open-a-modal-form-from-code-behind-i-now-nee

I asked how to open a modal form and how to close the modal form..

As a related issue:

1) Please would you advise on which javascript files and functions are absolutely essential close a modal form ?; and

2) Where the javascript methods should be referenced in terms of the calling/hosting page and modal form?

Thanks & Regards

mrplatypus.

Answer posted by Dan Letecky [DayPilot]
6 years ago.

With the default settings, the modal dialog uses an iframe to display the content. That means the content is working with a different window context.

In order to open the modal dialog, you need to include daypilot-modal.js from https://code.daypilot.org/81367/daypilot-modal. The latest version is 2.5 but one of the older versions can be included in a specific tutorial/demo. It's recommended to use the latest version so you have access to the latest API.

There are two ways to close the modal dialog:

1. From the parent window (that one which opened the modal dialog):

DayPilot.ModalStatic.close();

2. From the modal dialog itself:

Method 1 - reach the parent context:

window.parent.DayPilot.ModalStatic.close();

No extra libraries are needed, the parent context already has access to daypilot-modal.js.

Method 2:

Include daypilot-modal.js in the modal page itself and call:

DayPilot.Modal.close();

3. If the modal page is an ASP.NET WebForm you can use the server-side helper (DayPilot.Modal.cs from https://code.daypilot.org/81367/daypilot-modal) and call Util.Modal.Close() on PostBack. This will complete the PostBack and close the modal dialog.

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.