Skip to main content
Inspiring
December 15, 2008
Question

I am in Middle of CFC

  • December 15, 2008
  • 1 reply
  • 843 views
I implement my ajax Delete functionality and it works fine within a grid.

it delete the records.

But i have a image related to the delete functionality. whenever i run that function my image do not get deleted.

how can i change the code to make it work:

here is my code:

function deleteTheme() {
var proxyp = new DeleteThe();
proxyp.setErrorHandler(errorHandler);
proxyp.setCallbackHandler(DeleteCallback);

var dID = ColdFusion.getElementValue('Grid01','Form1','ID');
proxyp.DeleteThe(dID);
<cfajaxproxy cfc="cfc.cfc1" jsclassname="DeleteThe">

this code runs the cfc function which delete the joke.

i tried adding the functionality like in a cfc in different function

<cfif fileexists('imagefile')>
<cffile action=delete" file="path">
</cfif>

but it did not worked out
This topic has been closed for replies.

1 reply

Inspiring
December 16, 2008
you will need to code the delete file process into your DeleteThe
function in your cfc.
you are passing some id to your function -> query the db to get the
filename associated with that id -> delete the file if it exists ->
delete the record from your db

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Inspiring
December 16, 2008
<cffunction ...>
<cfargument ...>
<cfset VAR mydel = "">
<cfset VAR myq = "">
<cfset VAR imagepath = "path/to/where/you/store/the/images/">
<cfquery name="myq" ...>
SELECT imagefilenamecolumn
FROM themes
WHERE themeID = <cfqueryparam cfsqltype="cf_sql_numeric"
value="#trim(arguments.themeID)#">
</cfquery>
<cfif fileexists(imagepathe & myq.imagefilenamecolumn)>
<cffile action="delete" file="#imagepath & myq.imagefilenamecolumn#">
</cfif>
<cfquery name="mydel" ...>
...
</cfquery>
</cffunction>

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Inspiring
December 16, 2008
Thanks AZADI..

Well one new thing i learned the two queries you used in a single cffuntion tags.

well any number of queries can be used in one cffuntion

Yes/No

Thanks