0

I'm trying to update the content of a TinyMCE textarea when the user closes a child Fancybox window. This is the function that executes on close which works because my alert is displaying:

$(".popup").fancybox({
          'afterClose': function (){
             var content = $('#profile').html('<span>NEW CONTENT</span>');
            // document.getElementById('profile').value = $_returnvalue;

             alert($_returnvalue);
        },
        });
    });

When I put the following line in function document ready it works so I am guessing it is something to do with TinyMCE updating after page load? Grateful for any help.

var content = $('#profile').html('<span>NEW CONTENT</span>');
Tom Hughes
  • 83
  • 5
  • If that is your actual code, then you have syntax errors (extra closing brackets and unnecessary trailing commas), otherwise it works http://jsfiddle.net/596v7/ – JFK Apr 15 '14 at 16:17
  • Hi, ignore the extra close tag, there is an opening function that this relates to. I also get it working on a blank text box, but when I convert the box to TinyMCE it won't work. I understand it is something to do with DOM and the way TinyMCE loads on page load - I think I need to somehow re-initiate? Thanks – Tom Hughes Apr 16 '14 at 15:46
  • its afterLoad function, not afterClose and you should use setTimeout to make wait after afterLoad is called. – Wasim A. Dec 26 '15 at 18:49
  • this may help http://stackoverflow.com/a/34474232/612987 – Wasim A. Dec 26 '15 at 18:57

0 Answers0