Load content
7 Sep 20172 minutes to read
BY default, the content inside the Dialog element is considered as the content for the Dialog component.
Also, we can render the Dialog component’s content through the following ways.
-
request through AJAX
-
request iframe content
-
request image content
This settings can be specified through contentType
property.
<ej-dialog id="basicDialog" title="Dialog" contentUrl="app\components\dialog\test.html" contentType="ajax"
[(allowKeyboardNavigation)]="keyboard" containment="#parent">
</ej-dialog>
Here below the content of that HTML file.
<div id="content">
This content is loaded via AJAX request.
</div>
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.
<ej-dialog id="basicDialog" title="Dialog" contentUrl="app\components\dialog\test.html" contentType="ajax"
containment="#parent" (ajaxSuccess)="onSuccess($event)" (ajaxError)="onError($event)">
</ej-dialog>
Add the following code in typescript file.
onSuccess(event) {
//handle success event
}
onError(event) {
//handle Error event
}
NOTE
The same way we can render the iframe and image content for the Dialog component by specifying the
contentType
as “iframe” and “image” respectively and also by specifying the proper location in thecontentUrl
property.