Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chuck 71 posts 69 karma points
    Aug 13, 2012 @ 22:56
    Chuck
    0

    Change Color of TinyMCE using Jquery

    We are using the True Color Picker to allow a user to choose a color that will be the background of an editable property that uses the TinyMCE rich text editor. We've already figured out how to change the colorpicker.js file to change the background color ot the TinyMCE iframe, however we cannot figure out how to set the color whent he TinyMCE editor initially loads. 

    In the colorpicker.js there are 2 functions. We've added a line of code on the setNewColor function to update the background color of the iframe, but when we add that same chunk of code to the setCurrentColor which we know loads when the page loads it doesn't effect the iframe. We think the setCurrentColor function won't update the background of the iframe because the iframe hasn't loaded yet. We tried adding a check inside the setCurrentColor to check if the iframe is loaded, but that did not work. Any ideas on what we could do to make sure that when a user goes to the node and clicks on the tab to edit this field the background will initially be set to the color that was saved previously? 

    setCurrentColor = function (hsb, cal) {
    $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
    },
    setNewColor = function (hsb, cal) {
    $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
    //added to change the background of the WYSIWYG when changing the colorpicker
     $("#body_prop_alertContent_ifr").contents().find("body").css('backgroundColor', '#' + HSBToHex(hsb));
    },

Please Sign in or register to post replies

Write your reply to:

Draft