Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

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

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
brianmfalls
Asked:
brianmfalls
1 Solution
 
soniethomasCommented:
Try changing

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

to

function tryThis() {
      alert('kilroy');
}
0
 
OnthraxCommented:
Add the onclick="tryThis();" to the image inside the td..
0
 
SandyAgoCommented:
Where do you include the jquery library?
0
 
brianmfallsAuthor Commented:
Why does that make the difference?  (Trying to learn.)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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