Difference between revisions of "Scripts 1 0-loadCFJS"
From ADF Docs
(Description) |
Gcronkright (talk | contribs) (→Usage:) |
||
| (25 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | __NOTOC__ | |
| + | Attention: Do not change any text in the description, signature, and paramter sections. | ||
| − | Description | + | Return to [[Scripts_1_0]] |
| + | |||
| + | == Description == | ||
| + | Loads the CFJS jQuery Plug-in Headers if not loaded. | ||
| + | |||
| + | == Signature == | ||
| + | public void <strong>loadCFJS</strong> ( string version ) | ||
| + | |||
| + | == Parameters == | ||
| + | |||
| + | <table id="lib-params"> | ||
| + | <tr class="header"> | ||
| + | <td>Required</td> | ||
| + | <td>Name</td> | ||
| + | <td>Type</td> | ||
| + | <td>Description</td> | ||
| + | </tr> | ||
| + | |||
| + | |||
| + | <tr> | ||
| + | |||
| + | <td class="required">optional</td> | ||
| + | |||
| + | <td>version</td> | ||
| + | <td>string</td> | ||
| + | <td>[Default: 1.1.9] CFJS version to load.</td> | ||
| + | </tr> | ||
| + | |||
| + | </table> | ||
| + | |||
| + | == Examples == | ||
| + | |||
| + | 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: === | ||
| + | Add the ADF loadJQuery() and loadCFJS() headers to the top of your custom script page: | ||
| + | <source lang="cfm"> | ||
| + | <cfscript> | ||
| + | // load jQuery headers | ||
| + | application.ADF.scripts.loadJQuery(); | ||
| + | // load jQuery CFJS headers | ||
| + | application.ADF.scripts.loadCFJS(); | ||
| + | </cfscript> | ||
| + | </source> | ||
| + | |||
| + | Using jQuery call the CFJS library functions: | ||
| + | <source lang="javascript"> | ||
| + | <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> | ||
| + | </source> | ||
| + | |||
| + | HTML: | ||
| + | <source lang="html4strict"> | ||
| + | <div id="valueDisplayA"></div> | ||
| + | <div id="valueDisplayB"></div> | ||
| + | </source> | ||
| + | |||
| + | Output: | ||
| + | <source lang="java"> | ||
| + | Three | ||
| + | 4 | ||
| + | </source> | ||
| + | |||
| + | === References: === | ||
| + | A complete CFJS Function listing:<br> | ||
| + | [http://cjordan.us/page.cfm/CFJS-function-listing-by-category/ Chris Jordan's Blog] | ||
| + | |||
| + | Quick reference site for CF functions and function parameters:<br> | ||
| + | [http://cfquickdocs.com/ cfquickdocs.com] | ||
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
4References:
A complete CFJS Function listing:
Chris Jordan's Blog
Quick reference site for CF functions and function parameters:
cfquickdocs.com