• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

[Coldfusion 2023]: "Coldfusion is not defined" error on cfselect bind attribute in cfform

Community Beginner ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

Hi,

We have recently upgraded from 2021 to 2023, and we are facing an issue in cfforms, binding is not working on cfselect. we have checked the cfscript directory location and scripts and everything is alligned. It will be great if someone can provide a solution please.

Ahsan5CDC_1-1709559102266.png

 

 

TOPICS
Asynchronous , Documentation , Server administration

Views

539

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Mar 05, 2024 Mar 05, 2024

Thank you @Charlie Arehart  for your help, web server and cf admin are configured perfectly fine. cf_scripts directory is automatically configured during installation and it has all the required packages and cfajax.js,  http://<yoursite>/cf_scripts/scripts/ajax/package/cfajax.js putting our website domain, gives us the required cfajax.js file. While exploration other workarounds, we found that some meta tag is conflicting with the cfselect bind which was working perfectly fine in cf2021.  We hav

...

Votes

Translate

Translate
Community Beginner ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

@Charlie Arehart Hi Charlie, can you please have a look and let me know what we can do to resolve the issue, let me know if you need more information about the error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

Can you clarify why you are @InG me here? Had we discussed this problem elsewhere, perhaps? I just don't recall.

 

If you're just making the plea because I help out a lot here, I'll say first that it's really not appropriate to tag specific people for that reason.

 

And I'll say second that I saw your note here this morning, and I WAS interested to explore the problem...but since you have no example code, I'd have to put that together myself...and the day got away from me. Even then, I'd be guessing whether I'd replicate your SPECIFIC problem. Is it as simple as being about cfselect WITHOUT binding? Or is it specific to DOING a binding?

 

You would help out me and anyone here who might help by your creating a simple few-line example (whether of one or two templates), that any of us could then run on our own or at cffiddle.org or trycf.com.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

Appologies for taggin you, I wanted that someone quickly reply and you are most active and have a high correct answer ratio, so thats why. Appologies if its against the community guidelines.

 

The issue is specifc to cfselect with binding only. other cfselect with query and options is working perfectly fine. 

the example code is below:

dependent_dropdown.cfc

<!-- dependent_dropdown.cfc  -->
<cfcomponent output="false">
    <cffunction name="getProgramLocations" access="remote" returnType="query">
        <cfquery name="data" datasource="#THIS.dsn#">     
            SELECT 'ALL' as data
            union all
            SELECT  data
            FROM application_dropdown
            WHERE Category='Program_Location'
        </cfquery>
        <cfreturn data>
    </cffunction>
</cfcomponent>

 form.cfm

<!-- form.cfm  -->
<cfform name="RegistrationForm" method="post" enctype="multipart/form-data">
<div class="col-md-4">
    <label>Exchange Program Location(Country visited)<span class="symbol required"></span></label>
	<cfselect  class="form-control" name="LocationId" selected="#LocationId#"  bind="cfc:dependent_dropdown.getProgramLocations()" bindonload="true"  id="LocationId">
	</cfselect>
	</div>
</cfform>

Errors generated in console:

<!-- Errors generated in console  -->
form.cfm:123 Uncaught ReferenceError: ColdFusion is not defined
    at form.cfm:123:2
<!-- On error click displays this auto generated javascript code -->
<script type="text/javascript">/* <![CDATA[ */
	ColdFusion.Ajax.initSelect('LocationId','','',[]);
/* ]]> */</script>

<script type="text/javascript">/* <![CDATA[ */
	_cf_bind_init_652421887470501=function()
	{
		ColdFusion.Bind.register([],{'bindTo':'LocationId','bindToAttr':'value','cfc':'/dependent_dropdown.cfc','cfcFunction':'getProgramLocations','_cf_ajaxproxytoken':'73EBBF80','bindExpr':[]},ColdFusion.Bind.cfcBindHandler,true);
	};ColdFusion.Event.registerOnLoad(_cf_bind_init_652421887470501);
/* ]]> */</script>

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 05, 2024 Mar 05, 2024

Copy link to clipboard

Copied

That's not the stand alone example I proposed, but let's move on. If you may be thinking "something broke in CF2023, since it worked in CF2021", I can confirm I now have a running cfselect with an ajax bind to a CFC working in CF2023. I suspect you'll find it's a configuration issue on your end--either in the web server or the CF Admin settings. 

 

Indeed, as for that error you get ("Coldfusion is not defined"), if you were to search for that, one of the discussions you'll find (https://stackoverflow.com/questions/56841983/cf2018-cfselect-binding-failure) also suggests the problem may be with your web server not serving correctly the cfscripts directory. And I have now confirmed that I can cause that same error in CF2023 by misconfiguring that.

 

But you said originally that "scripts and everything is alligned". Can you clarify? Are you saying that if you go to the Network tab of the developer tools (that you show using in the first post), there are no 404 errors for all the requests, especially to the cfajax.js file?

 

To be clear, by default the folder for those is cf_scripts (in the cfusion/wwwroot folder) in CF2016 and above, whereas it was cfscripts--without an underscore (in the cfusion/wwwroot/CFIDE folder) in CF11 and earlier. And if you're using a web server like IIS or Apache, the CF web server connector would automatically create a virtual directory/alias within those, to point to this folder. Again, the default for that would be cf_scripts.

 

Then as you may know there is a CF admin settings page to allow one to change the name of this "default script src path" (to something other than cf_scripts), if you somehow want to use a different one. In that case, the value of the virtual directory/alias in the web server has to be set to use that name.

 

All these things have to be "aligned", and that's what you'd want to see succeeding in that Network tab. In a default setup, this url would return javascript&colon; http://<yoursite>/cf_scripts/scripts/ajax/package/cfajax.js. What does it return for you?

 

Let us know if this gets you going, or what you find.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 05, 2024 Mar 05, 2024

Copy link to clipboard

Copied

LATEST

Thank you @Charlie Arehart  for your help, web server and cf admin are configured perfectly fine. cf_scripts directory is automatically configured during installation and it has all the required packages and cfajax.js,  http://<yoursite>/cf_scripts/scripts/ajax/package/cfajax.js putting our website domain, gives us the required cfajax.js file. While exploration other workarounds, we found that some meta tag is conflicting with the cfselect bind which was working perfectly fine in cf2021.  We have included 

<!--[if IE]><meta http-equiv='X-UA-Compatible' content="IE=edge,IE=9,IE=8,chrome=1" /><![endif]-->

This meta tag was conflicting with cfselect bind, after removal of this tag, all the cfselect with binding has started working. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation