Controls the JavaScript files that are imported for use on pages that use ColdFusion AJAX tags and features.
<cfajaximport cssSrc = "local URL path" params = "parameters" scriptSrc = "local URL path" tags = "comma-delimited list">
Note: You can specify this tag's attributes in an attributeCollection whose value is a structure. Specify the structure name in the attributeCollection and use the tag's attribute names as structure keys. |
cfform, cfgrid, cfinput, cflayout, cfmenu, cfpod, cfsprydataset, cftextarea, cftooltip, cftree, cfwindow, Specifying client-side support files in the Developing ColdFusion Applications
ColdFusion 8: Added this tag.
Attribute |
Req/Opt |
Default |
Description |
---|---|---|---|
cssSrc |
Optional |
scriptsrc/ajax |
Specifies the URL, relative to the web root, of the directory that contains the CSS files used by ColdFusion AJAX features, with the exception of the rich text editor. This directory must have the same directory structure, and contain the same CSS files, and image files required by the CSS files, as the web_root/CFIDE/scripts/ajax/resources directory. |
params |
Optional |
|
This attribute allows you to specify parameters for the CFM page. Currently, the only parameter that you can specify is googlemapkey. You can specify the googlemapkey as follows:<cfajaximport params=#{googlemapkey="Map API Key"}#> |
scriptSrc |
Optional |
scriptsrc setting in the Administrator;default path is /CFIDE/scripts/ |
Specifies the URL, relative to the web root, of the directory that contains the client-side script files used by ColdFusion. This directory includes the JavaScript files and the default location of the CSS files used for all AJAX features. If you use this attribute, the cfajaximport tag must precede all other ColdFusion AJAX tags on the page; that is, all tags that rely on the scripts. |
tags |
Optional |
|
A comma-delimited list of tags or tag-attribute combinations for which to import the supporting JavaScript files on this page. |
The scriptsrc attribute is useful if the JavaScript files are not in the default location. This attribute is required in some hosting environments and configurations that block access to the /CFIDE directory. The default scriptsrc value is determined by the Default CFFORM ScriptSrc Directory setting on the Server Settings > Settings page of the ColdFusion Administrator. For cfform tags, the tag's scriptsrc attribute takes precedence over this attribute.
You can use this attribute only if the cfajaximport tag is on a top-level page; that is, a page that the client directly requests. You cannot use it, for example, on a page that is specified in a cfwindow tag source attribute.
When you use the cfajaximport tag with a scriptsrc attribute, the specified directory must have the same structure as the /CFIDE/scripts directory. For example, if you specify scriptsrc="/resources/myScripts", the JavaScript files used by AJAX must be in the /resources/myScripts/ajax directory. This attribute specifies the folder that contains the ColdFusion client-side files for all subsequent tags on the current page, not just for AJAX-based tags. Therefore, the directory tree must include all ColdFusion client-side files used by those tags. For example, if a cfform tag on the page is in Flash or applet format, include the CF_RunActiveContent.js file in the directory specified by the scriptsrc attribute.
You use the cssSrc attribute to specify the location of the CSS files required by ColdFusion AJAX features. This attribute overrides the scriptsrc/ajax/resources directory for the current page. Therefore, if all pages that use a custom scriptsrc directory also use a custom cssSrc directory, you do not have to include the ColdFusion AJAX CSS files in the scriptsrc directory tree.
If you do not use the cfajaximport tag on a page that contains ColdFusion tags with AJAX UI features, ColdFusion correctly imports the required JavaScript files in most cases. Use this tag to explicitly import JavaScript files in these cases:
Attribute value |
Used for |
---|---|
cfdiv |
cfdiv tags |
cfform |
Forms that are in cfpod, cfwindow, or cflayoutarea tag bodies |
cfgrid |
AJAX format cfgrid tags |
cfinput-autosuggest |
cfinput tags that use the autosuggest attribute |
cfinput-datefield |
HTML format cfinput tags that use the datefield attribute |
cflayout-border |
cflayout tags with a type attribute value of border |
cflayout-tab |
cflayout tags with a type attribute value of tab |
cfmenu |
cfmenu tags |
cfpod |
cfpod tags |
cfsprydataset-JSON |
cfsprydataset tags that generate Spry JSON data sets |
cfsprydataset-XML |
cfsprydataset tags that generate Spry XML data sets |
cftextarea |
HTML format cftextarea tags |
cftooltip |
cftooltip tags |
cftree |
HTML format cftree tags |
cfwindow |
cfwindow tags |
The following cfajaximport tag example specifies separate custom locations for the scripts used for AJAX features and for the AJAX CSS files. It also imports all JavaScript files used for cftree, and cftooltip.
<cfajaximport cssSrc="/collegeApp/application/cssFiles" scriptsrc="/collegeApp/ajaxScripts" tags="cftooltip, cfwindow">
Sign in to your account