Difference between revisions of "Scripts 1 0-loadCFJS"

From ADF Docs
Jump to: navigation, search
(References:)
(Usage:)
Line 37: Line 37:
  
 
=== Usage: ===
 
=== Usage: ===
Add the loadCFJS() headers to the top of your custom script page:
+
Add the ADF loadJQuery() and loadCFJS() headers to the top of your custom script page:
 
<source lang="cfm">
 
<source lang="cfm">
<cfscript>
+
<cfscript>
 
     // load jQuery headers
 
     // load jQuery headers
     application.ptProfile.scripts.loadJQuery();
+
     application.ADF.scripts.loadJQuery();
 
     // load jQuery CFJS headers
 
     // load jQuery CFJS headers
     application.ptProfile.scripts.loadCFJS();
+
     application.ADF.scripts.loadCFJS();
</cfscript>
+
</cfscript>
 
</source>
 
</source>
  
 
With your jQuery functions call the CFJS library:
 
With your jQuery functions call the CFJS library:
 
<source lang="javascript">
 
<source lang="javascript">
<script>
+
<script>
 
     jQuery(function(){
 
     jQuery(function(){
 
// define a list
 
// define a list
Line 66: Line 66:
 
alert(strPos); // Displays the value 4
 
alert(strPos); // Displays the value 4
 
     });
 
     });
</script>
+
</script>
 
</source>
 
</source>
  

Revision as of 20:32, 13 August 2010

Attention: Do not change any text in the description, signature, and paramter sections.

Return to Scripts_1_0

Description

Loads the CFJS jQuery Plug-in Headers if not loaded.

Signature

public void loadCFJS ( string version )

Parameters

Required Name Type Description
optional version string [Default: 1.1.9] CFJS version to load.

Examples

CFJS is a jquery plugin written by [Christopher Jordan] that contains a library of "ColdFusion style" functions (ie. ArrayLen(), GetListAt() and ListFindNoCase(), etc.) for use in jQuery/JavaScript code.

Usage:

Add the ADF loadJQuery() and loadCFJS() headers to the top of your custom script page:

<cfscript>
     // load jQuery headers
     application.ADF.scripts.loadJQuery();
     // load jQuery CFJS headers
     application.ADF.scripts.loadCFJS();
</cfscript>

With your jQuery functions call the CFJS library:

<script>
     jQuery(function(){
	// define a list
        var numStrList = "One,Two,Three,Four,Five";

        // use CFJS to get the value of the item at position 3 of the list
	var numStrText = jQuery.ListGetAt(numStrList,3,','); // list,position,delimiter

        // display the value of the numStrText variable 
	alert(numStrText); // displays the string 'Three'
        
        // use CFJS to find the position of the string 'Four' from the list
        var strPos = jQuery.ListFindNoCase(numStrList,'Four',',');

        // Display the position of the string
	alert(strPos); // Displays the value 4
     });
</script>

References:

CFJS Function listing:
Chris Jordan's Blog

Quick reference site for CF functions and function parameters:
cfquickdocs.com