Difference between revisions of "Scripts 1 0-loadCFJS"

From ADF Docs
Jump to: navigation, search
(Usage:)
 
(16 intermediate revisions by the same user not shown)
Line 34: Line 34:
 
== Examples ==
 
== Examples ==
  
CFJS is a jquery plugin written by [[Christopher Jordan|http://cjordan.us/archives.cfm/category/cfjs]] that contains a library of "ColdFusion style" functions (ie. ArrayLen(), GetListAt() and ListFindNoCase(), etc.) written for use in jQuery/JavaScript code.  
+
CFJS is a jquery plugin written by [http://cjordan.us/archives.cfm/category/cfjs Christopher Jordan] that contains a library of "ColdFusion style" functions (ie. ArrayLen(), GetListAt() and ListFindNoCase(), etc.) for use with jQuery/JavaScript code.  
  
 
=== 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("1.3.2");
+
     application.ADF.scripts.loadJQuery();
 
     // load jQuery CFJS headers
 
     // load jQuery CFJS headers
     application.ptProfile.scripts.loadCFJS("1.1.9");
+
     application.ADF.scripts.loadCFJS();
</cfscript>
+
</cfscript>
 
</source>
 
</source>
  
With your jQuery functions call the CFJS library:
+
Using jQuery call the CFJS library functions:
 
<source lang="javascript">
 
<source lang="javascript">
<script>
+
<script>
 
     jQuery(function(){
 
     jQuery(function(){
 
// define a list
 
// define a list
         var valueList = "One,Two,Three,Four";
+
         var numStrList = "One,Two,Three,Four,Five";
  
         // get the value of the item at position 3 of the list
+
         // use CFJS to get the value of the item at position 3 of the list
var valuePos = jQuery.ListGetAt(valueList,3,',');
+
var numStrText = jQuery.ListGetAt(numStrList,3,','); // list,position,delimiter
  
         // Display the string 'Three'
+
         // output the value of the numStrText variable
alert(valuePos);  
+
jQuery('#valueDisplayA').html(numStrText); // displays the string 'Three'
 +
       
 +
        // use CFJS to find the position of the string 'Four' from the list
 +
        var strPos = jQuery.ListFindNoCase(numStrList,'Four',',');
 +
 
 +
        // output the position of the string
 +
jQuery('#valueDisplayB').html(strPos);  
 
     });
 
     });
</script>
+
</script>
 
</source>
 
</source>
  
=== References: ===
+
HTML:  
CFJS Function listing:
+
<source lang="html4strict">
[[http://cjordan.us/page.cfm/CFJS-function-listing-by-category/]]
+
<div id="valueDisplayA"></div>
 +
<div id="valueDisplayB"></div>
 +
</source>
  
Quick reference site for CF functions and function parameters:
+
Output:
[[http://cfquickdocs.com/]]
+
<source lang="java">
 +
Three
 +
4
 +
</source>
  
<!--
+
=== References: ===
Using the getCSTaxObj function is simple and straight forward. Making a call to this method will return a component which contains all of the Taxonomy API calls available in the CommonSpot Taxonomy.
+
A complete CFJS Function listing:<br>
 
+
[http://cjordan.us/page.cfm/CFJS-function-listing-by-category/ Chris Jordan's Blog]
=== CE Data calls return Taxonomy Term ID ===
 
If you have Taxonomy fields inside your Custom Element and you make calls to get data for that custom Element using CEData, the Taxonomy fields will return term ID's.  You can convert those term ID's using code like this:
 
<source lang="cfm">
 
<cfscript>
 
    // custom element data
 
    data = application.ADF.ceData.getCEData("My Element");
 
    // returns taxonomy object
 
    taxObj = application.ADF.taxonomy.getCSTaxObj("My Taxonomy");
 
</cfscript>
 
  
<cfloop from="1" to="#arrayLen(data)#" index="itm">
+
Quick reference site for CF functions and function parameters:<br>
    <!---// renders the term name instead of the term id --->
+
[http://cfquickdocs.com/ cfquickdocs.com]
    <cfoutput>#taxObj.getTermName(data[itm].values.myTaxField)#</cfoutput>
 
</cfloop>
 
</source>
 
-->
 

Latest revision as of 20:50, 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 with 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>

Using jQuery call the CFJS library functions:

<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

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

        // output the position of the string
	jQuery('#valueDisplayB').html(strPos); 
     });
</script>

HTML:

<div id="valueDisplayA"></div>
<div id="valueDisplayB"></div>

Output:

Three
4

References:

A complete CFJS Function listing:
Chris Jordan's Blog

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