开发者

Rails 3 and Tinymce: Displaying text editor only when focus is on text box?

开发者 https://www.devze.com 2023-02-28 07:58 出处:网络
Is it possible to only display a rich 开发者_Python百科text editor when the focus turns to a text area? I have a form with about 15 different text areas and i don\'t want each one displaying the edito

Is it possible to only display a rich 开发者_Python百科text editor when the focus turns to a text area? I have a form with about 15 different text areas and i don't want each one displaying the editor tab when they are not in use.

Thanks


Yes, this is possible.

You will need to set the mode to "exact" in the tinymce init. Plus you will need to initialize the right tinymce editor when the textarea gets the focus.

$('#mytextarea').focus(function() {
  alert('Handler for .focus() called.');
  tinymce.execCommand('mceAddControl',true, $('#mytextarea').attr("id"));
});

To shut down an editor instance use:

tinymce.execCommand('mceRemoveControl',true, editor_id);
0

精彩评论

暂无评论...
验证码 换一张
取 消