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

Javascript daypilot-modal-2.2.js Error issue..

Asked by mrplatypus
3 years ago.

After successfully modifying some rows in the database, I am now getting an error..
JavaScript runtime error: Function Expected...

Dan and Team: Any answers to resolve this issue please?

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

Very strange, since the function seems to be defined.

One thing to check is the context from which you call the .close() method.

To close the modal dialog from the parent simply call .close() on the instance:

var modal = new DayPilot.Modal();
//...
modal.close()

To close it from within the modal page there are two options:

1. The older method which accesses the parent window (pre-2.2 versions):

if (parent && parent.DayPilot && parent.DayPilot.ModalStatic) {
  parent.DayPilot.ModalStatic.close();
}

2. Since 2.2 you can simply call:

DayPilot.Modal.close(result);

In this case you need to include modal.js in the modal page (otherwise it won't be able to access DayPilot.Modal object).

Let me know if it didn't help.

Comment posted by mrplatypus
3 years ago.

Dan,

A bit of additional information:

The error is occurring from the RecurrentEventEdit.aspx page the resulting effect is that the modal form does not close?

The standard workflow is maintained, with the condition of implementing my own database update...
So the flow is: source page -> RecurrentEditMode.html -> RecurrentEventEdit.aspx page..

Have you any thoughts, please?

Thanks

mrplatypus (a.k.a Dave)

Comment posted by mrplatypus
3 years ago.

Dan,

Also, the close is being called from the code-behind page..

mrplatypus (a.k.a. Dave)

Comment posted by mrplatypus
3 years ago.

Dan,

Another bit of information:

I think that this is a problem with IE, particularly:

Version: 11.0.9600.18230
Update Versions: 11.0.29 (KB3139929)

As when trying an alternative browser, the modal dialog box hides.

Comment posted by mr platypus
3 years ago.

Dan and Team,

Have you any comments please?

Thanks
mrplatypus (a.k.a. Dave)

Comment posted by Dan Letecky [DayPilot]
3 years ago.

To be honest, I don't know what could be causing this issue. The function being called (DayPilot.ModalStatic.result) is clearly defined just below.

Have you tried to inspect what the value of DayPilot.ModalStatic.result is at the breakpoint? What is the value of DayPilot.ModalStatic?

I assume you are using the latest server-side part of DayPilot.Modal which looks like this:

namespace Util
{

    /// <summary>
    /// Summary description for Modal
    /// </summary>
    public class Modal
    {

        public static void Close(Page page)
        {
            Close(page, null);
        }

        public static string Script(object result)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script type='text/javascript'>");
            sb.Append("if (parent && parent.DayPilot && parent.DayPilot.ModalStatic) {");
            sb.Append("parent.DayPilot.ModalStatic.close(" + new JavaScriptSerializer().Serialize(result) + ");");
            sb.Append("}");
            sb.Append("</script>");

            return sb.ToString();
        }

        public static void Close(Page page, object result)
        {
            page.ClientScript.RegisterStartupScript(typeof(Page), "close", Script(result));
            return;
        }

    }

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