Calling a function when I close a CFWindow - How?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Haitashi
    New Member
    • Jun 2007
    • 96

    Calling a function when I close a CFWindow - How?

    I have a link and opens up a CFWindow. I'm using the default CFWindow skin. I would like to execute a specific function when the user clicks on the X button.

    I would like to show a div (which will be hidden by default) when I close the CFWindow. I assume I can use ColdFusion.Wind ow.onHide somehow but I don't know how.

    All the examples I've seen on the net use a href link to call the onHide handler. I would like to call this event handler when a user closes the window using the X that comes by default in the CFWindow ...er...window? :)

    Thanks in advance!
  • Haitashi
    New Member
    • Jun 2007
    • 96

    #2
    Ok. I got it to work but only slightly...

    On my display page I have this:
    Code:
    <cfset AjaxOnLoad("setCFWindowHooks") />
    And on the included JS file for that page I have this:
    Code:
    function hideJavaLoader(name) {
    	console.log('You just opened ' + name + ' CFWINDOW');
    	$('.applet').hide();
    }
    //This will show the Java uploader when a video window is closed
    function showJavaLoader(name) {
    	console.log('You just hid ' + name + ' CFWINDOW');
    	$('.applet').show();
    }
    setCFWindowHooks = function() {
    	console.info("Adding ColdFusion window hooks...");
    	ColdFusion.Window.onShow('myVideo', hideJavaLoader);
    	ColdFusion.Window.onHide('myVideo', showJavaLoader);
    	console.info("...done");
    };
    This code is only working in FF and firebug might be the reason why. If I eliminate those "console.lo g" statements, then it stops working. I don't get it. Any ideas?

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      I've not really worked with CFWindow (had no need to), but according to this, your code should work. Try an alert and see if that works.

      Comment

      • bishopt
        New Member
        • Feb 2010
        • 1

        #4
        Some more info to consider ---

        You should be able to run any Javascript function automatically via ColdFusion.Wind ow.onHide

        I'd look at the $('.applet').sh ow() and .hide() statements.

        Replace them with simple alerts to ensure they are being called, then debug them.

        For example, if you have a div with an id of 'myDiv', and you want to show it when the cfwindow is closed, call a javascript function that looks like this:

        function showDiv(){
        $('myDiv').styl e.display="bloc k";}

        the hide function would be
        function hideDiv(){
        $('myDiv').styl e.display="none ";}

        Comment

        • Haitashi
          New Member
          • Jun 2007
          • 96

          #5
          Awesome! I had totally given up on this. Ty bishopt. :)

          Comment

          Working...