Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
You create the function and you set it up to be called the way the Message Box knows how to call it and then you add a bit of code to link it all together. I'm still working in the index.cfm file, in the photographers directory of the application. I'll start by creating a function that will be called when the user clicks either the Yes or the No box on the MessageBox component. I will name my new function doDelete. Because this is going to be set up as a callback function for the MessageBox component, it will be called in a certain way.
It's going to be passed a parameter and the parameter's value will be the name of the button that was clicked in lowercase. I will name this parameter btn. Then I will create a pair of curly braces and within the function I'm going to use an alert method and just output the value of that parameter or argument that was passed in, btn. So now, to test that function I'll go down to the cfmessagebox tag. In the cfmessagebox tag I'll add a new attribute named callbackhandler.
So that's how callback functions work in the world of Ajax and in the world of the new ColdFusion Ajax tools such as the ColdFusion MessageBox component. Represented here with the cfmessagebox tag and activated by the call to ColdFusion.MessageBox.show. The doDelete function will now be responsible for responding to when the user clicks one of the two buttons and I'll finish this entire workflow in the final video of this chapter.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101001 Viewers
61 Video lessons · 87790 Viewers
71 Video lessons · 71666 Viewers
56 Video lessons · 103555 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.