May 09, 2008
For ColdFusion hosting try HostMySite.com. |
Home /
Groups /
ColdFusion Talk (CF-Talk)
CFWindow with forms
I'm looking for some sample use of cfwindow using a form and closing the cfwindowcoldfusion.developer 03/25/08 05:23 P here's one i use:Azadi Saryev 03/25/08 11:29 P Hi,Dave Ferguson 03/27/08 01:39 A I'm looking for some sample use of cfwindow using a form and closing the cfwindow once the form passes validation and backend processing. I've search and found a few great articles by Ray Camden, but I wanted to see the whole thing put together to grasp the entire concept. http://www.coldfusionjedi.com/index.cfm/2007/7/27/Update-to-ColdFusionBloggersorg-Ajaxbased-Contact-Form Any direction, link etc would be great. here's one i use: *cfwindow content - add_collection.cfm - loaded into an 'add-new-gallery-window' cfwindow:* <!--- ---> <cfset err = 0> <cfset errmsg = "<strong>Please correct the following errors and submit the form again:</strong><br />"> <cfif isdefined('form.submitbtn')> <!--- validate input ---> <cfif len(trim(form.collection_title)) is 0> <cfset err = 1> <cfset errmsg = errmsg & "• Gallery Title is required.<br>"> </cfif> <cfif len(trim(collection_description)) is 0> <cfset err = 1> <cfset errmsg = errmsg & "• Gallery Decription is required.<br>"> </cfif> <cfif err is 0> <!--- insert data ---> <cfinvoke component="..." method="..." returnvariable="result"> <cfinvokeargument name="..." value="#trim(form.collection_title)#"> <cfinvokeargument name="..." value="#trim(form.collection_description)#"> </cfinvoke> <cfif result is true> <script>onAddNewSuccess('add-new-gallery-window', onHideAddGallery);</script> <cfelse> <cfset err = 1> <cfset errmsg = "Error creating gallery!"> </cfif> </cfif> </cfif> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script> hideWindow = function(){ ColdFusion.Window.hide('add-new-gallery-window'); } </script> </head> <body> <cfform name="addgallery" action="#getfilefrompath(cgi.SCRIPT_NAME)#" method="post" style="width:100%;"> <cfoutput> <cfif err gt 0> <div class="row"> <div class="errors"> #errmsg# </div> </div> </cfif> <div class="row"> <span class="label">Title:</span> <span class="formfield"><cfinput type="text" name="collection_title" value="#form.collection_title#" required="yes" message="Enter Gallery Title." /></span> </div> <div class="row"> <span class="label">Description:</span> <span class="formfield"><cftextarea name="collection_description" style="height:100px;" required="yes" message="Enter Gallery Description.">#form.collection_description#</cftextarea></span> </div> <div class="row"> <cfinput type="submit" name="submitbtn" value="Save"> <cfinput type="button" name="cancelbtn" value="Cancel" onClick="hideWindow();"> </div> </cfoutput> </cfform> </div> </body> </html> *calling page (highly abbreviated)* <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> openWindow = function(name,title,url,options){ ColdFusion.Window.create(name, title, '', options); ColdFusion.navigate(url, name); } addGallery = function(){ openWindow('add-new-gallery-window', 'Add Image Gallery', 'add_collection.cfm', {center:true,height:400,width:650,minheight:400,minwidth:650,closable:false,dragable:true,resizable:true,modal:true,initshow:true}); } onHideAddGallery = function(name){ //some code to run after cfwindow closes - i update the galleries drop-down list } </head> <body> .... .... <a href="javascript:addGallery();">[ add new gallery ]</a> .... .... </div> </body> </html> HTH! Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ coldfusion.developer@att.net wrote: ----- Excess quoted text cut - see Original Post for more ----- Hi, While Azadi's solution will work it will cause you an issue. Using coldfusion.window.hide does exactly what it says, the window is just hidden. The window is still using client resources and you can still reference the window and its content. What I have used is a scheme to create dynamic window names and use a destroy action to remove the window completely. There is however a current bug in CF8 that the window is not completely destroyed. From what I have heard this should be fixed soon. You can check out this entry from my blog on how to do dynamic window creation. http://blog.dkferguson.com/index.cfm/2008/2/6/alter-window-close-function --Dave blog.dkferguson.com
|
Mailing Lists
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||