• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 893
  • Last Modified:

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

0
paddycobbett
Asked:
paddycobbett
  • 2
1 Solution
 
Scott BennettManager TechnologyCommented:
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

0
 
Scott BennettManager TechnologyCommented:
sorry I copy/pasted that poorly the link should be like:
<A href="javascript:ColdFusion.navigate('emailpage.cfm', 'mainDiv');">open email</A>

Open in new window

0
 
paddycobbettAuthor Commented:
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! :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now