Link to home
Start Free TrialLog in
Avatar of paddycobbett
paddycobbett

asked on

Coldfusion8 <CFDIV> calling ajax from javascript issue

Please look at the attached code which i've simplified for purposes of my issue.

Now you can see that the index.cfm just declares a <CFDIV> for the purposes of loading content into it. The initial content is maincontent.cfm. Within maincontent.cfm i have used the ajaxlink function so that what it links replaces the current content within the cfdiv. Now my issue is this, is there a way to do this without calling the ajaxlink function? The link below it, which calls openEmailPage() is actually generated html from the cf code, and so can not plant an #ajaxlink()# around the link url. Currently the openEmailPage simply forwards to the emailpage.cfm, but i actually want the emailpage.cfm to embed within the cfdiv. How can i ammend the js code to acheive what i'm trying to do.

I don't think i'm doing anything out of the ordinary so i'm sure there's a standard way of doing this, i'm just don't know what that is! Can anyone help me out please? :)

Please ask questions if i haven't explained myself properly.
index.cfm
=======
 
<HTML>
<BODY>
 
<CFDIV bind="url:maincontent.cfm">
 
</BODY>
</HTML>
 
maincontent.cfm
============
 
<SCRIPT>
	function openEmailPage(){
		window.location = "emailpage.cfm";
	}
</SCRIPT>
 
<A href="#ajaxlink("contacts.cfm")#">go to contacts page</A>
 
<!--- this html link is generated from the result of a cfc call --->
<A href="javascript: onclick="openEmailPage();">open email</A>

Open in new window

Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

use the ColdFusion.navigate function.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=JavaScriptFcns_24.html
index.cfm
=======
 
<HTML>
<BODY>
 
<CFDIV name="mainDiv" bind="url:maincontent.cfm">
 
</BODY>
</HTML>
 
maincontent.cfm
============
 
<A href="#ajaxlink("contacts.cfm")#">go to contacts page</A>
 
<!--- this html link is generated from the result of a cfc call --->
<A href="javascript: onclick="ColdFusion.navigate("emailpage.cfm", "mainDiv");">open email</A>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott Bennett
Scott Bennett
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
Avatar of paddycobbett
paddycobbett

ASKER

Thanks, just what i was looking for. It worked with one slight ammendment, the CFDIV must be given the id attribute a value rather than the name attribute, otherwise the navigate function claims to not find the div. Many thanks! :)