Solved

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

Posted on 2010-08-17
4
415 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
4 Comments
 
LVL 2

Accepted Solution

by:
soniethomas earned 500 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to resize a div in html 3 35
suddenly angular cli doesn't work. 5 38
ability to create nested list on the UI using PHP, HTML, Javascript 7 43
Ahax pagination 9 32
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a pageā€¦
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
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)

809 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