Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Opening a modal by closing another

  1. #1
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Opening a modal by closing another

    I have a application that is opening a dhtmlmodal window and based on the action chosen it will close and do nothing; do something backend and then close; close and then open a new modal shortly after.

    This last one i am having trouble as I am assigning trying to open the new modal from a custom onclose function. I have attached the code below, the onclose is triggered by a function in the auditpop modal by calling parent.auditpop.close();

    If anyone had any ideas or advise i would very much appreciate it.

    Code:
    function auditPopup(){
    		var map = {"userid" : temp_user,"edit" : "false"};
    		jQuery.ajax({
    			type: "GET",
         		url: '/auditwizard-portlet/checkInProgress.jsp',
         		dataType: "html",
         		data: map,
         		global: true,
         		success: function(responseHTML){
         			var audit_war = "/auditwizard-portlet/view.jsp?userid="+temp_user;
         			auditpop = dhtmlmodal.open("auditbox","iframe",audit_war,"Athena Audit Wizard","width=600px,height=280px,scrolling=1,center=0,top=5px,left=5px");
    				auditpop.onclose = function(){
    					audit_type = this.contentDoc.getElementById("prog_audited_type").innerHTML;
    					audit_app = this.contentDoc.getElementById("prog_audited_app").innerHTML;
    					audit_time = this.contentDoc.getElementById("prog_audited_timestamp").innerHTML;
    					audit_grace = this.contentDoc.getElementById("prog_audited_gracePer").innerHTML;
    					audit_save = this.contentDoc.getElementById("prog_audited_saveDate").innerHTML;
    					audit_last = this.contentDoc.getElementById("prog_audited_lastDate").innerHTML;
    					audit_auditee = this.contentDoc.getElementById("prog_audited_auditee").innerHTML;
    					audit_assigner = this.contentDoc.getElementById("prog_audited_assigner").innerHTML;
    					audit_ressignee = this.contentDoc.getElementById("prog_audited_reassignee").innerHTML;
    					audit_user = temp_user;
    					audit_params = "type="+audit_type+"&app="+audit_app+"&timestamp="+audit_time+"&graceper="+audit_grace+"&savedate="+audit_save+"&lastdate"+audit_last+"&auditee="+audit_auditee+"&assigner="+audit_assigner+"&reassignee="+audit_reassignee+"&userid="+audit_user;
    					alert(audit_params);
    					auditWizPop();
    				};
    					
         		},
         		error: function(xhr, status, e){
         			if(xhr.status ==500){
         				alert("Please Contact Athena with error descript");
         			}else if(xhr.status == 404){
         			}else{
         				alert("Error has occured with "+xhr.status);
         			}
         		}
         	});
    	}
    	
    function auditWizPopup(){
    	
    		var auditwizURL = "/auditwizard-portlet/application_audit_wizard.jsp?"+audit_params;
    		audit_wizard = dhtmlmodal.open("audit_wiz","iframe",auditwizURL,"Athena Audit Wizard (In Progress...)","width=1180px,height=700px,scrolling=1,center=0,top=5px,left=5px");
    		audit_wizard.onclose =	function(){var audit_data = this.contentDoc.getElementById("audit_main_div").innerHTML;  
    											var audit_app = this.contentDoc.getElementById("wiz_audited_app").innerHTML;
    											var audit_time = this.contentDoc.getElementById("wiz_audit_timestamp").innerHTML;
    											
    											var map = {"random" : Math.floor(Math.random()*1000)
    														, "app" : audit_app
    			  											, "user" : "<%out.print(users);%>"
    			  											, "time" : audit_time
    			  											, "data" : audit_data};
    											
    											jQuery.ajax({
    												type: "POST",
    												async: false,
    												url: '/auditwizard-portlet/SaveAuditToDB.jsp',
    												dataType: "html",
    												data: map,
    												global: true,
    												success: function(responseHTML){
    													alert("Save Successful");
    													audit_wizard.hide();
    												},
    												error: function(xhr, status, e){
     														if(xhr.status ==500){
     																alert("Please Contact Athena with error description");
     														}else if(xhr.status == 404){
     														}else{
     															alert("Error has occured with "+xhr.status);
     														}
     												}
    											
    											});
    										};

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There's a lot you're not showing us, a link to the page might be required. But since AJAX is involved, that might not be enough. It might be something simple though -

    I'm assuming this alert fires:

    Code:
    					alert(audit_params);
    					auditWizPop();
    				};
    That would be what's telling you that auditWizPop should fire, but from what you say, it doesn't. The obvious reason would be that there is no function named auditWizPop. There is one named auditWizPopup, try that and see if it works:

    Code:
    					alert(audit_params);
    					auditWizPopup();
    				};
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Unfortunately I cannot post a link to the page as it is exists within my company's intranet.

    I did fix the auditWizPopup() function call. The alert did execute and so did the new window open, but now oddly enough the auditpop.onclose function is no longer doing anything not oddly enough it is not, which is driving me crazy.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Oddly enough, I'm not sure I understand what you're saying here.

    Looks like we solved the first problem though.

    And it sounds like those other things were working before and that they aren't now. If that stuff was happening before, my guess would be that they depended upon the time and/or environment alloted to them due to the previous error.

    Like if the now functioning callback (auditWizPopup) overwrites one or more things that the onclose function needs and/or produces, that would mess things up.

    It would still probably help if you could put up a demo of this somewhere live.

    It doesn't have to give away any company secrets. It just has to demonstrate the problem(s) you're having. Make it as simple as possible, while still showing the problem(s).

    Often just setting up something like that will cause the insight you need to see where the current code is going wrong.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry i didn't correct my grammar last post. The problem I am experiencing now is that in the auditpop.onclose function it is catching a error that shouldn't exist and is closing the window before the variable can be set.

    SO
    Code:
    audit_type = this.contentDoc.getElementById("prog_audited_type").innerHTML;
    in the auditpop.onclose function is caught as an errorin the catch statement in the dhtmlwindow.close function, which it shouldn't as the element exists in the modal window at the time the onclose function is called, and i am using IE and the catch is for non IE browsers. Then the dhtml close function proceeds to forget the rest of the onclose function and close the auditpop modal, and call the auditWizPopup function which gets stuck in an infinite loop looking for values, or something.

  6. #6
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    My only guess is that it is not liking the this.contentDoc which has worked in the past for me, and i haven't changed anything to prevent it from working in the js files.

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Now I am confused. I thought you said everything else was working before you fixed the error with auditWizPop/auditWizPopup.

    Now it seems there were problems before that was fixed.

    In any case, this.contentDoc is non-standard. Unless you've defined it elsewhere, it's undefined. It looks like this.contentDocument, which can refer to the document object in a window. I've only ever seen this used in reference to an iframe's content document. But I suppose it could have other uses. However, in my experience it's not very cross browser.

    If you're using AJAX though, everything should be in either the responseText or responseXML, whichever you're fetching*, there and of course (for the page that is doing the fetching) in the document object itself.


    *If using jQuery.ajax as it appears you are, whichever of these that's fetched is the first argument of the success function - what you're calling the responseHTML.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You gave me an ephiphany originally the jQuery.ajax method was just in place as a check to proceed with audits however it made me look closer and see that the return is same as when it is called again in the modal window that is opened. it will take some restructuring but it may just fix this entire issue.

  9. #9
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok i cleared the issue of this.contentDoc by eliminating it. Thank you know i am back to my original issue. Only the window opens but during the opening process it fails to do so.

    Is there a way to modify the modal's contents and attributes (width, height, etc) without closing. Such if i clicked a button, it would go from 500px by 400px (w by h);displaying a couple button, it would display a different page and would now be 1180px by 700px (w by h)?

  10. #10
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mclerojb58 View Post
    Ok i cleared the issue of this.contentDoc by eliminating it. Thank you know i am back to my original issue. Only the window opens but during the opening process it fails to do so.
    By this I meant that, that grabbing data is no longer an issue but now the new modal will appear but fail half-way through and not display what it should.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •