0 0

请问用cleditor内容如何赋值啊5

请问下用cleditor 我用的$('#field_content').val("所要显示的值");显示不出来 field_content是这个编辑器的id

问题补充:
myali88 写道
你用的是什么版本?我用1.3试了试,这样可以的啊:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>XHTML Plug-in Demo - CLEditor WYSIWYG HTML Editor</title>
    <meta name="description" content="CLEditor is an open source jQuery plugin which provides a lightweight, full featured, cross browser, extensible, WYSIWYG HTML editor that can be easily added into any web site." />
    <meta name="keywords" content="jquery plugin, wysiwyg, html, editor, cross browser, lightweight, open source" />
    <link rel="stylesheet" type="text/css" href="jquery.cleditor.css" />
    <script type="text/javascript" src="jquery-1.6.min.js"></script>
    <script type="text/javascript" src="jquery.cleditor.min.js"></script>
    <script type="text/javascript" src="jquery.cleditor.xhtml.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
       $("#input").cleditor()
       $("#input").val('xxxx');
      });
    </script>
    </head>
    <body>
    	<textarea id="input" name="input">The XHTML plug-in allows CLEditor to produce Transitional XHTML compliant source. After formatting some text click the Show Source button on the toolbar to view the generated XHTML.</textarea>
    </body>
</html>

显示效果上都能出来,但是使用“val()”时,其内部的iframe内容并没有更新,使用html()时,textarea和iframe内容都更新了,我建议你使用html

额 请问怎么使用html呢?我的这个cleditor是放在一个dialog里面的

问题补充:
myali88 写道
就这样:
$("#input").html('你要显示的内容');  //input是你绑定的textaea的id


额 还是不可以显示 如果是一般textarea的话就可以 看来是cleditor的问题

问题补充:
myali88 写道
引用
额 还是不可以显示 如果是一般textarea的话就可以 看来是cleditor的问题

你把它绑定一般的html元素上了吗?这肯定不行,要绑到textarea上,富文本编辑器都是这样使用的,实现的原理也都是这样的。

我帮了的啊
$('#field_content').html("我要现实这个");
$(document).ready(function(){
   $("#field_content").cleditor();
}
<body>
<textarea id="field_content" name="content" style="width:150px"></textarea>
</body>

问题补充:
myali88 写道
你把顺序换成这样试试:
$(document).ready(function(){
   $("#field_content").cleditor();
   $('#field_content').html("我要现实这个");
}
<body>
<textarea id="field_content" name="content" style="width:150px"></textarea>
</body>

你把
$('#field_content').html("我要现实这个");
放在ready外面赋值怎么赋值得上去呢。textarea对象都取不到的。

我囧了 还是不行 我不用cleditor就用textarea的话就可以 看来是cleditor自己的问题把

问题补充:
myali88 写道
引用
我囧了 还是不行 我不用cleditor就用textarea的话就可以 看来是cleditor自己的问题把

把你的页面传上来,我下载测试一下。

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'test.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/common.css" />	
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/common.css" />	


<script src="<%=path %>/js/jquery/jquery-1.6.2.min.js" type="text/javascript"></script> 
<script src="<%=path %>/plugins/jquery-ui-1.8.14.custom/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script> 
<script src="<%=path %>/plugins/CLEditor1_3_0/jquery.cleditor.min.js" type="text/javascript"></script>  
<script type="text/javascript"> 
$(document).ready(function(){
	$("#field_content").cleditor();
	$("#field_content").text("我要现实这个");
}

</script>
  </head>
  
  <body>
   <textarea id="field_content" name="content" style="width:150px"></textarea>
  </body>
</html>

问题补充:
myali88 写道
引用
我囧了 还是不行 我不用cleditor就用textarea的话就可以 看来是cleditor自己的问题把

把你的页面传上来,我下载测试一下。

弄错了 我这个
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'test.jsp' starting page</title>

<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/common.css" />	
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/common.css" />	
<link rel="stylesheet" href="../../css/plugins/jquery-ui-1.8.14/base/jquery.ui.all.css"/>
<link rel="stylesheet" href="<%=path %>/plugins/CLEditor1_3_0/jquery.cleditor.css" type="text/css">


<script src="<%=path %>/js/jquery/jquery-1.6.2.min.js" type="text/javascript"></script> 
<script src="<%=path %>/plugins/jquery-ui-1.8.14.custom/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script> 
<script src="<%=path %>/plugins/CLEditor1_3_0/jquery.cleditor.min.js" type="text/javascript"></script>  
<script type="text/javascript"> 
$(document).ready(function(){
	$("#field_content").cleditor();
	$("#field_content").html("我要现实这个");
})

</script>
  </head>
  
  <body>
   <textarea id="field_content" name="content" style="width:150px"></textarea>
  </body>
</html>

问题补充:
myali88 写道
哎,你引用的js还差一个啊:
    <script type="text/javascript" src="jquery.cleditor.xhtml.min.js"></script>

这个你怎么没引用进来呢?

我囧了 我下载的包里面没这个js文件啊 而且网上也找不到

问题补充:
myali88 写道
引用
我囧了 我下载的包里面没这个js文件啊 而且网上也找不到

我下载的包里面就包含了啊!http://premiumsoftware.net/cleditor/,这里下载的!

也是只有jquery.cleditor.css
jquery.cleditor.js、jquery.cleditor.min.js和图片
没有xhtml.min.js文件啊
2011年8月23日 21:40

11个答案 按时间排序 按投票排序

0 0

采纳的答案

确实,我下载下来也没看看,但是我上次下载,自己电脑上是有的。不管怎么样,就用现在下载的这个也可以做到:

$(document).ready(function() {
        var o = $("#input").cleditor()[0];//关键是这里获取第一个对象,否则upateFrame无法调用
	$('#input').html('<h1>aaaaa</h1>');
	o.updateFrame();
});

HTML:
  <body>
    <textarea id="input" name="input">sssssssssssssssssssss</textarea>
  </body>

关键的地方上面已经说明了,我也测试过,可以的。可能是.cleditor()方法不像其他的jquery插件那样,内部使用迭代,导致返回直接就是一个数组,所以调用不了upateFrame.

2011年8月29日 11:11
0 0

引用
我囧了 我下载的包里面没这个js文件啊 而且网上也找不到

我下载的包里面就包含了啊!http://premiumsoftware.net/cleditor/,这里下载的!

2011年8月28日 21:28
0 0

CLEditor 是的一个jquery的Plugins这个要另外下载的
http://plugins.jquery.com/project/CLEditor到这里下·

2011年8月28日 19:41
0 0

哎,你引用的js还差一个啊:

    <script type="text/javascript" src="jquery.cleditor.xhtml.min.js"></script>

这个你怎么没引用进来呢?

2011年8月25日 21:02
0 0

引用
我囧了 还是不行 我不用cleditor就用textarea的话就可以 看来是cleditor自己的问题把

把你的页面传上来,我下载测试一下。

2011年8月25日 13:26
0 0

你把顺序换成这样试试:

$(document).ready(function(){
   $("#field_content").cleditor();
   $('#field_content').html("我要现实这个");
}
<body>
<textarea id="field_content" name="content" style="width:150px"></textarea>
</body>

你把
$('#field_content').html("我要现实这个");
放在ready外面赋值怎么赋值得上去呢。textarea对象都取不到的。

2011年8月25日 11:34
0 0

引用
额 还是不可以显示 如果是一般textarea的话就可以 看来是cleditor的问题

你把它绑定一般的html元素上了吗?这肯定不行,要绑到textarea上,富文本编辑器都是这样使用的,实现的原理也都是这样的。

2011年8月24日 12:12
0 0

$("#field_content").text("所要显示的值");   
这个不行么?

2011年8月24日 11:39
0 0

就这样:

$("#input").html('你要显示的内容');  //input是你绑定的textaea的id

2011年8月24日 09:41
0 0

你用的是什么版本?我用1.3试了试,这样可以的啊:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>XHTML Plug-in Demo - CLEditor WYSIWYG HTML Editor</title>
    <meta name="description" content="CLEditor is an open source jQuery plugin which provides a lightweight, full featured, cross browser, extensible, WYSIWYG HTML editor that can be easily added into any web site." />
    <meta name="keywords" content="jquery plugin, wysiwyg, html, editor, cross browser, lightweight, open source" />
    <link rel="stylesheet" type="text/css" href="jquery.cleditor.css" />
    <script type="text/javascript" src="jquery-1.6.min.js"></script>
    <script type="text/javascript" src="jquery.cleditor.min.js"></script>
    <script type="text/javascript" src="jquery.cleditor.xhtml.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
       $("#input").cleditor()
       $("#input").val('xxxx');
      });
    </script>
    </head>
    <body>
    	<textarea id="input" name="input">The XHTML plug-in allows CLEditor to produce Transitional XHTML compliant source. After formatting some text click the Show Source button on the toolbar to view the generated XHTML.</textarea>
    </body>
</html>

显示效果上都能出来,但是使用“val()”时,其内部的iframe内容并没有更新,使用html()时,textarea和iframe内容都更新了,我建议你使用html

2011年8月23日 23:10
0 0


<script type="text/javascript">
      $(document).ready(function() {
        $("#field_content").cleditor({width:500, height:180, useCSS:true})[0].focus();

//试试这个方法
$("#field_content").text("所要显示的值");   
   });

    </script>



 <textarea id="field_content" name="field_content"></textarea>

2011年8月23日 22:55

相关推荐

    CLEditor1_3_0

    CLEditor1_3_0是一款基于Java的轻量级文本编辑器组件,主要适用于Web应用程序,为用户提供在网页上编辑文本的功能。这个jar包包含了所有必要的类和资源,使得开发者可以方便地集成到他们的项目中,提供用户友好的富...

    CLEditor1_3_0.zip

    【标签】"CLEditor1_3_0.zip" 重复了文件名,这可能是为了便于识别和分类,表明这个压缩包的内容与CLEDITOR 1.3.0版本紧密相关。 【压缩包子文件的文件名称列表】: 1. `jquery.cleditor.js`:这是CLEDITOR的主要...

    CLEditor1_4_3.zip

    5. **应用场景**:CLEDITOR适用于那些需要在网页上收集或展示富文本内容的场景,比如博客评论、论坛发帖、文章编辑等。由于其轻量级的特性,对于资源有限的网站来说,CLEDITOR是一个很好的选择。 6. **扩展与社区**...

    ClEditor实用编译器

    在**描述**中提到的"整合java实现"意味着ClEditor是基于Java平台构建的,利用Java的强大功能和跨平台性,确保用户无论在哪个操作系统上都能享受到一致的使用体验。Java的面向对象特性使得ClEditor可以模块化设计,...

    CLEditor v1.3.0

    7. **使用方法**:一般情况下,引入 jQuery 和 CLEditor 的 JavaScript 文件后,通过 jQuery 选择器选取元素并调用 `.cleditor()` 方法即可初始化编辑器。例如: ```javascript $("#myEditor").cleditor(); ``` ...

    CLEditor源代码

    4. `使用帮助.txt`:这是一个文本文件,可能包含了关于如何使用和配置CLEditor的详细说明,对于初次接触这个编辑器的开发者来说非常有帮助。 5. `chinaz.com.txt`和`谷普下载.url`:这些可能是指向更多资源或下载...

    cleditor_fork

    使用cleditor_fork时,开发者需要具备一定的JavaScript和jQuery知识,因为cleditor是基于jQuery构建的。通过引入jQuery库和cleditor_fork的JS文件,可以将编辑器绑定到页面上的任何文本输入元素。此外,了解CSS有助...

    WYSIWYG Editor2.3网页编辑器.rar

    WYSIWYG Editor2.3,不依赖于任何一款JS插件,不过使用有第三方组件,已打包在压缩内。WYSIWYG Editor可见即所得编辑器支持ASP/PHP/ASP.NET等WEB开发环境,压缩包内自带有15款调用例子,新手也可快速上手WYSIWYG ...

    ResponsiveFilemanager:完全响应的Filemanager,集成了tinyMCE,CKEditor和CLEditor编辑器

    该脚本会自动为预览列表创建图像的缩略图,并且还可以创建要在cms或站点中使用的外部缩略图。 可以将其配置为自动调整上传图像的大小或自动限制尺寸。 您可以个性化每个文件夹的配置。 您可以将子文件夹设置为根...

    PSEditor:jQuery插件

    jquery.cleditor.plugin.js-Cleditor插件(源) jquery.pseditor.min.js-jQuery插件(最小化) jquery.pseditor.css-样式表(源) images / buttons.gif-CLEditor工具栏按钮图像条 images / toolbar.gif-...

    文档编辑器

    最后,我们来看到“cleditor”这个文件名,它可能是指这款文档编辑器的源代码编辑器部分,用于编写和编辑代码。这对于程序员和开发者来说尤其重要,因为它支持语法高亮、代码折叠、自动完成等特性,提高代码编写效率...

    精选的10款用于构建良好易用性网站的jQuery插件

    6. **CLEditor**:作为一款轻量级的WYSIWYG编辑器,CLEditor支持多种浏览器,易于集成,使用户能够在网页上进行富文本编辑,提升了内容创作的便利性。 7. **jDownload**:jDownload插件增强了下载管理,当用户点击...

    bustracking:跟踪公交车

    该项目中使用的jQuery插件fullcalendar.min.jsjquery.chosen.min.jsjquery.cleditor.min.jsjquery.cookie.jsjquery.dataTables.min.jsjquery.elfinder.min.jsjquery.flot.jsjquery.flot.pie.jsjquery.flot.resize....

    reMarked.js.zip

    reMarked.js 是一个跟 Markdownify 类似的项目,其最终目的是集成已有的 WYSIWYG html 编辑器(例如: TinyMCE, CKeditor, Loki, CLeditor) 来生成 Markdown 输出。目前还没有针对 Markdown 的可视化编辑器。 ...

    基于Bootstrap的后台管理面板 Bootstrap Metro Dashboard

    这是一款基于Bootstrap的Metro风格的后台管理面板应用,Bootstrap Metro Dashboard的UI是基于Twitter Bootstrap样式的,同时使用了jQuery 1.9.1和jQuery UI组件,非常适合做网站的后台管理系统界面。 Bootstrap ...

Global site tag (gtag.js) - Google Analytics