Load content

24 Oct 20183 minutes to read

BY default, the content inside the Dialog element is considered as the content for the Dialog widget.

Also, we can render the Dialog widget content through the following ways.

  1. request through AJAX

  2. request iframe content

  3. request image content

This settings can be specified through contentType property.

  • JAVASCRIPT
  • $("#dialog").ejDialog({
                    title: "Dialog",
                   //create a HTML file (dialogContent.html) which contains the content for the dialog                        
                    contentUrl: "dialogContent.html",
                    contentType: "ajax"
                });

    Here below the content of that HTML file.

  • HTML
  • <div id="content">
            This content is loaded via AJAX request.
        </div>

    Load content

    We can handle the AJAX request’s success and failures through the events ajaxSuccess and ajaxError events respectively. See also ajaxSuccess and ajaxError

    The previous example is modified as below to handle the success and failure events.

  • JAVASCRIPT
  • $("#dialog").ejDialog({
                    title: "Dialog",
                   //create a HTML file (dialogContent.html) which contains the content for the dialog                        
                    contentUrl: "dialogContent.html",
                    contentType: "ajax",
                    ajaxSuccess: "onSuccess",
                    ajaxError:"onError"
                });
    
            function onSuccess(args) {
                //handle success event
            }
            function onError(args) {
                //handle success event
            }

    NOTE

    The same way we can render the iframe and image content for the Dialog widget by specifying the contentType as “iframe” and “image” respectively and also by specifying the proper location in the contentUrl property. If you wish to dynamically change the dialog content, you can set the contentUrl and the contentType property through setModel on any action.