How to automatic resize tinyMCE?

后端 未结 12 1474
小蘑菇
小蘑菇 2020-12-01 09:03

I have a TinyMCE that is set over a TextArea, and I want this editor area to ocuppy all the space of its parent div, all times.

I have a JS function that get the cur

12条回答
  •  無奈伤痛
    2020-12-01 09:36

    If you're doing tiny MCE dynamically via JS, you can run into timing issues where the MCE editor is not yet available for style adjustments. To combat this, you can use an old school timeout.

    In this example, I'm using a "j" namespace for JQuery. If your editor is in a fluid div that changes size, you may want include this in a $(window).resize(function() { }); listener.

    setTimeout(function(){ 
      $j('.mceEditor').css('width','100%').css('minHeight','240px');
      $j('.mceLayout').css('width','100%').css('minHeight','240px');
      $j('.mceIframeContainer').css('width','100%').css('minHeight','240px');
      $j('#'+[INSERT TEXTAREA ID HERE]+'_ifr').css('width','100%').css('minHeight','240px');
    },500) 
    

提交回复
热议问题