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

SCRIPT tag in application.cfm causes bind to fail!

Community Beginner ,
May 22, 2008 May 22, 2008

I have two cfselect boxes one bound to the other via a cfc.
However if I include some javascript into application.cfm the bind stops working ?

Anyone have any ideas?

Code :
art.cfc
==============
<cfcomponent output="false">

<cfset THIS.dsn="cfartgallery">

<!--- Get array of media types --->
<cffunction name="getMedia" access="remote" returnType="array">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>

<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT mediaid, mediatype
FROM media
ORDER BY mediatype
</cfquery>

<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result [1]=data.mediaid>
<cfset result [2]=data.mediatype>
</cfloop>

<!--- And return it --->
<cfreturn result>
</cffunction>

<!--- Get art by media type --->
<cffunction name="getArt" access="remote" returnType="array">
<cfargument name="mediaid" type="numeric" required="true">

<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>

<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT artid, artname
FROM art
WHERE mediaid = #ARGUMENTS.mediaid#
ORDER BY artname
</cfquery>

<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result [1]=data.artid>
<cfset result [2]=data.artname>
</cfloop>

<!--- And return it --->
<cfreturn result>
</cffunction>

</cfcomponent>

=============
testme.cfm
=============
<cfform>
<BR><BR><BR>
<table>
<tr>
<td>Select Media Type:</td>
<td><cfselect name="mediaid"
bind="cfc:art.getMedia()"
bindonload="true" /></td>
</tr>
<tr>
<td>Select Art:</td>
<td><cfselect name="artid"
bind="cfc:art.getArt({mediaid})" /></td>
</tr>
</table>

</cfform>

===========
application.cfm (WORKING)
===========
<CFAPPLICATION name="CREQ_DEV"
clientstorage="Registry"
clientmanagement="Yes"
setclientcookies="Yes"
sessionmanagement="Yes"
sessiontimeout="#createtimespan(0,6,0,0)#"
applicationtimeout="#createtimespan(0,6,0,0)#"

loginstorage="session"
>





Application.cfm (BIND STOPS WORKING WORK)
===========
<CFAPPLICATION name="CREQ_DEV"
clientstorage="Registry"
clientmanagement="Yes"
setclientcookies="Yes"
sessionmanagement="Yes"
sessiontimeout="#createtimespan(0,6,0,0)#"
applicationtimeout="#createtimespan(0,6,0,0)#"

loginstorage="session"
>
<script type="text/javascript">
function selectAll(list)
{
for (i=0; i<list.length; i++) {
list.options .selected = true;
}
}
</script>

=======================

TOPICS
Advanced techniques
303
Translate
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

LEGEND , May 22, 2008 May 22, 2008
it stops working because your application.cfm attaches your script to
data returned by your cfc, breaking its expected returned format (json
by default, iirc).

try to avoid outputting anything in your application.cfm/cfc - it's not
a good practice.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
LEGEND ,
May 22, 2008 May 22, 2008
it stops working because your application.cfm attaches your script to
data returned by your cfc, breaking its expected returned format (json
by default, iirc).

try to avoid outputting anything in your application.cfm/cfc - it's not
a good practice.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
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 ,
May 22, 2008 May 22, 2008
LATEST

Sorted. Putting a big IF statement on it worked a treat.
I'll work towards removing the includes but theres a lot of them in there.
Translate
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