Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JavaScript not working from onClick of td element of coldFusion document.  It's REALLY frustrating!

Posted on 2010-08-17
4
Medium Priority
?
420 Views
Last Modified: 2012-06-27
For reasons beyond my sight, the onClick of my td doesn't work.  The error console tells me that the function being called is not defined.  BUT IT IS!!!  There has to be something simple that is eluding me here.  Any help would be appreciated.

Everything works, unless I try to access a function from onClick of the first table.  I am going to go poke myself in the eye now.  Should be more fun than dealing with this...
<!-------------------------------------------------
	document				element.templateForm
	author				brianmfalls
	date					08.03.2010
	last modified on		08.03.2010
	last modified by		brianmfalls
	last modified notes:	document created
!------------------------------------------------->

<cfoutput>

<cfset url.templateID = 88>
<cfset this.template = numberFormat(url.templateID, "00000")>
<cfset this.elementsPath = replaceNoCase(cgi.script_name, "index.cfm", "") & request.thisModule & "/uiElements/">


	<script type="text/javascript">
		$(document).ready(function(){
			templateBG = new Image();
			templateBG.src = "http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_01.png";
			templateBG = new Image();
			templateBG.src = "http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_02.png";
			templateBG = new Image();
			templateBG.src = "http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_03.png";
			templateBG = new Image();
			templateBG.src = "http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_04.png";
			templateBG = new Image();
			templateBG.src = "http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_05.png";
			templateBG = new Image();
			templateBG.src = "http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_06.png";
			templateBG = new Image();
			templateBG.src = "http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_07.png";
		});
	
		$(function tryThis() {
				alert('kilroy');
			});
	
		$(function enable_ckeditor() {
				$('##ckeditorInstance').fadeIn(900);
			});
	
		$(function() {
			var config = {
				toolbar:
				[
					['Source'],
					['Cut','Copy','Paste','PasteText','PasteWord','-','SpellCheck'],
					['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
					['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
					['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
					['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
					['Link','Unlink'],
					['Style','FontFormat','FontName','FontSize'],
					['TextColor','BGColor'],
				]
			};
			
			// Initialize the editor.
			// Callback function can be passed and executed after full instance creation.
			$('.jquery_ckeditor').ckeditor(config);
		});
	</script>
	
	<table cellspacing="0" cellpadding="0" class="template">
		<tr>
			<td style=" width: 628px; height: 693px; background-image: url(/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_03.png); " id="textContent" class="cluetip" title="#application.contentClue#" onclick="tryThis();" colspan="2">
				<img src="http://#cgi.http_host#/userfiles/#application.clientId#/templates/#this.template#/template_#this.template#_03.png" width="628" height="693">
			</td>
		</tr>
	</table>
	
	<div id="ckeditorInstance" class="modalForm" style=" display: none">
		<div id="floatThis" class="formBorder">
			<form action="" method="post" id="ck_form">
				<table>
					<tr>
						<td>
							<textarea class="jquery_ckeditor" cols="80" id="editor1" name="editor1" rows="10"></textarea>
						</td>
					</tr>
					<tr>
						<td style=" text-align: right; "><input type="submit" value="Place Content"></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	
	<script type="text/javascript">
		
		$(document).ready(function() {
	
			/////////////////////////////////////////////////	for ck_form instance /////////////////////////////////////////////////
			$('##ck_form').submit(function() {
				var editor = $('.jquery_ckeditor').ckeditorGet();
				var contentToPlace = $('.jquery_ckeditor').val();
				document.getElementById('textContent').innerHTML = '<div style=" width: 95%; height: 95%; overflow: hidden; margin: 0px; padding: 0px">' + contentToPlace + '</div>';
				if (contentToPlace.length >= 750) {
					$('##Notification').jnotifyAddMessage({
						text: '<h3>WARNING!!!</h3><p>If the content being placed is greater in size than its container, the excess content will be truncated (hidden).  Please verify that the content being added is complete post to placement and make corrections accordingly.</p><h4>WARNING!!!</h4>',
						permanent: true,
						type: 'error' }); }
				$('##ckeditorInstance').fadeOut(900);
				return false;
			});
		
		});
		
	</script>

</cfoutput>

Open in new window

0
Comment
Question by:brianmfalls
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Accepted Solution

by:
soniethomas earned 2000 total points
ID: 33459394
Try changing

$(function tryThis() {
                        alert('kilroy');
                  });

to

function tryThis() {
      alert('kilroy');
}
0
 
LVL 13

Expert Comment

by:Onthrax
ID: 33459671
Add the onclick="tryThis();" to the image inside the td..
0
 
LVL 2

Expert Comment

by:SandyAgo
ID: 33464104
Where do you include the jquery library?
0
 
LVL 1

Author Closing Comment

by:brianmfalls
ID: 33464934
Why does that make the difference?  (Trying to learn.)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question