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.
I think this is related to this thread. I have a link that I click that generates a new iframe appends it to the body but it fires the page twice.
If in the igDialog definition I add the temporaryURL, it causes it to call the server 4 times! lol
Also when the window is closed, everything works great, but it appears to call the Server AGAIN for the modal window that I had opened, which based on your explanation above makes sense that it fired it again because it is apparently changing the parents target. but how do I stop it, or put the control where it needs to belong to stop the multiple calls...
function openNewDialogWindow(frameId, pagePath, frameHeight, frameWidth) {
$.ig.loader(function () {
var framecontainer = "#" + frameId;
if ($(framecontainer).length > 0) {$(framecontainer).igDialog("open");}
else {
$('<iframe id="' + frameId + '" src="' + pagePath + '">').appendTo('body');
$(framecontainer).hide();
$(framecontainer).igDialog({
height: frameHeight,
width: frameWidth,
headerText: "Risk Acknowledgement Form",
footerText: pagePath,
modal: true,
showFooter: true
});
$(framecontainer).on({igdialogstatechanged: function (e, args) {
if (args.action == "close") {
$(framecontainer).off();
$(framecontainer).igDialog("destroy");
$(framecontainer).remove();
$("#AcknowledgementsLead").igGrid("dataBind");
}
Hi gmbart01,
The igDialog does not trigger those postback events intentionally. You may experiment with prebuilding final layout of dialog manually and passing layout elements explicitly into options.var container = document.body;//or reference to formvar mainElem = $('<div />').appendTo(container);var iframe = $('<iframe id="myIframe" src="..." />').appendTo(mainElem);iframe.igDialog({ mainElement: mainElem, container: container, .... });
Got it!
so I got rid of the .appendTo on the jquery frame creation and just replaced it with a staright igDialog with the references to the elements as you had given in the example. no more double post! you guys might want to update your documentation for this control.
var containerdata = document.body;var mainElem = $('<div />').appendTo(containerdata);var pagePath = '<%=Page.ResolveClientUrl("~/")%>AssetTeam/AddTeamMember/' + selectedAssetTeam;
$('<iframe id="' + frameId + '" src="' + pagePath + '">').igDialog({ height: 600, width: 1000, headerText: "Search for Users To Add", footerText: pagePath, modal: true, showFooter: true, mainElement: mainElem, container: containerdata});
thanks, the on close event that was causing it to fire the page again seems to have been alleviated,
however I'm still getting double posts when opening the window. I'll try to move it around and see where it needs to sit, but thanks for the close issue... clicking continue on the js errors was getting to be annoying.