Hi, My codes are as below in as mvc view.
<input type="button" name="btnOpen" id="btnOpen" value="Open Dialog" /> <%= Html.Infragistics() .Dialog() .ContentID("divDialog") .State(DialogState.Closed) .Modal(true) .Height("740px") .Width("1040px") .CloseOnEscape(true) .Resizable(false) .Draggable(false) .Render() %>
<div id="divJobs"> <script> alert('test'); </script> </div>
When page is load it fires two times.
Is that bug? Does anyone have idea about this?
Thanx
Dharmendra
Hello Dharmendra,
This is very unusual behavior.
You can refer to the following online sample showing how to open dialog on button click - https://www.igniteui.com/dialog-window/basic-usage
Use the code shown there in your sample and inform me what the results are.
Hi Dharmendra,
Observed functionality is correct. Or better to say, that happens according to rules of browser related to object moved from one parent to another. The idea behind igDialog is to take content of target element, remove it from old parent and insert into dynamically created container of igDialog. If target element contains javascript statements, then after the move, a browser may decide to execute those statements.
When page is initially loaded, then browser loads content of body (including target-element designed for igDialog) and executes all possible javascripts: first alert appears.After body was loaded, the ready-event of jquery is raised, igDialog is created and moves target element from old container to igDialog. That move triggers execute of javascripts located in target element and second alert appears.
All that is not related to visibility of igDialog, but only to change of target's parent. If parent would be moved twice (igDialog would be created/initialized twice), then alert would appear 3 times, etc.
If application needs only one alert, then it may add condition which validates layout of target-element: if target-element is inside igDialog or still outside. According to that condition alert can be displayed before move to igDialog or after: that may depend on logic/expectations of application.