Link to home
Start Free TrialLog in
Avatar of 14_east
14_eastFlag for United States of America

asked on

Close Fancybox after Cold Fusion query in modal wimdow

I have a page that displays database results (member info).  When a member clicks on "edit", I have a working form pop open in a modal window using Fancybox.  Upon editing, and clicking "update", the cold fusion query runs and updates the database.  Right here, how do I close the modal and reload the original page?
Avatar of Coast Line
Coast Line
Flag of Canada image

jQuery.fancybox.close();
or if called from within iframe then:
parent.jQuery.fancybox.close();

here is code that updates the db:
<cfquery ...>
update ...
</cfquery>
<script>
parent.jQuery.fancybox.close();
</script>
========================================
but then you did say to reload parent page so just reload the page and don't worry about closing the fancybox as it will close when parent is reloaded as in:
<cfquery ...>
update ...
</cfquery>
<script>
parent.location.replace(parent.window.location.href);
</script>

good luck ...
Avatar of 14_east

ASKER

@dgrafx - I tried placing this attached code below the CF query... no luck.

<cfsavecontent variable="modalScript">
				<script type="text/javascript">
				$(document).ready(function() {
					$parent.jQuery.fancybox.close();
					
				});
				</script>
                </cfsavecontent>
                <cfhtmlhead text='#modalScript#' />

Open in new window

sorry for the misunderstanding - what I posted was meant to be taken literally ...

1. get rid of the cfhtmlhead tag
2. use the code exactly as I posted it
3. here it is again:
<cfquery ...>
       update whatever ...
</cfquery>
<script>
parent.location.replace(parent.window.location.href);
</script>
and that's it!

Note that I am reloading page instead of closing fancybox because you want to do both, as reloading will close fancybox.
How to close fancybox (if you decide that's what you want to do) is in my previous post.
Avatar of 14_east

ASKER

Hmm... I tried the literal copy n paste, didn't work.  Ill go try it again!!
ya know - you need to eliminate the whole cfsavecontent thing you are doing as well.
just the query then the script I posted ...
Avatar of 14_east

ASKER

I copied as you had it... it still updates, but does not trigger the close function.  Below is my exact code... I am on CF8.


<cfif IsDefined ('form.updateMemberInfo')>
	  <!--- call tag for form validation --->
	  <cfmodule template="tags/TagValidateMemberEditForm.cfm">
	  <!--- setting session vars for form validation --->
	 <cfset session.m_firstname = "#form.m_firstname#">
     <cfset session.m_lastname = "#form.m_lastname#">
     <cfset session.m_phone = "#form.m_phone#">
	 <cfset session.m_address1 = "#form.m_address1#">
	 <cfset session.m_address2 = "#form.m_address2#">
	 <cfset session.m_city = "#form.m_city#">
	 <cfset session.m_state = "#form.m_state#">
	 <cfset session.m_zip = "#form.m_zip#">
	 <cfset session.m_creditscore = "#form.m_creditscore#">
	 <cfset session.m_networth = "#form.m_networth#">
	 <cfset session.m_liquidity = "#form.m_liquidity#">
		<!--- If there are no errors ---> 
  		<cfif request.FieldInvalid NEQ "Yes">
			<!--- Update user info --->
			<cfquery datasource="#request.dsn#">
			UPDATE tbl_borrower 
			SET m_firstname = '#form.m_firstname#',
			m_lastname = '#form.m_lastname#',
			m_phone = '#form.m_phone#',
			m_address1 = '#form.m_address1#',
			m_address2 = '#form.m_address2#', 
			m_city = '#form.m_city#', 
			m_state = #form.m_state#, 
			m_zip = '#form.m_zip#', 
			m_creditScore = '#form.m_creditScore#', 
			m_netWorth = '#form.m_netWorth#', 
			m_liquidity = '#form.m_liquidity#', 
			m_step = '1'
			WHERE ID = '#session.LoggedUser#'
			</cfquery>
				<cfset session.LoggedUserStep = "1">
                
				<script>
				parent.location.replace(parent.window.location.href);
				</script>
         </cfif>
	</cfif>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dgrafx
dgrafx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
anything?
Avatar of 14_east

ASKER

I had found a temporary solution, then went on vacation!  I will post more later on when I shift back to the project.
well like I said - if you are submitting via ajax then you'll need to put my code in the success function ...