TinyMCE提示文字 [英] TinyMCE hint text

查看:644
本文介绍了TinyMCE提示文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Remy Sharp的jQuery插件在文本框中显示提示.

I'm using Remy Sharp's jQuery plugin to display hints in text boxes.

我想对 TinyMCE 进行同样的操作-显示提示,例如"Type some text here.",当用户将重点放在TinyMCE编辑器上时,该文本将消失.如果编辑器为空(未输入文本),则在模糊时,该文本应再次可见.

I'd like to do the same with TinyMCE - display a hint, like "Type some text here.", and when the user focuses the TinyMCE editor, that text should go away. If the editor is empty (no text entered), then on blur the text should be visible again.

是否有能够做到这一点的jQuery插件?还是TinyMCE中有可以用于此功能的API?

Is there a jQuery plugin that is capable of doing this? Or is there an API in TinyMCE that I could use for this functionality?

推荐答案

TinyMCE应该传递文本区域中已有的任何内容,因此

TinyMCE should pass through any content already in the textarea, so

<textarea name="content" id="content">Type some text here</textarea>

应显示该文本,然后使用jQuery,您应该可以执行以下操作:

should display that text, then with jQuery you should be able to do something like:

TinyMCE.focus(function(){
 if ($(this).getContent() == "Type some text here"){
  tinyMCE.setContent("");
 } else if ($(this).getContent() == ""){
  tinyMCE.setContent("Type some text here");
 }
})

我还没有测试过,但是getContent& setContent是您从tinyMCE api中需要的...不确定.focus()是否能正常工作. TinyMCE用iframe替换了文本区域,因此您实际上不再需要输入文本区域...

I haven't tested it, but getContent & setContent is what you need from the tinyMCE api... not sure if the .focus() will work right. TinyMCE replaces the textarea with an iframe, so you're not actually typing into the textarea anymore...

这篇关于TinyMCE提示文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆