如何在asp.net中使用CKEditor的按类? [英] How to use CKEditor by class in asp.net?

查看:146
本文介绍了如何在asp.net中使用CKEditor的按类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使按类类型的CKEditor?
例如,我尝试以下code,但得到的错误:

  $(文件)。就绪(函数(){
    VAR txtArea = $(CKEditor的。);
    CKEDITOR.replace(txtArea,{});
});


解决方案

CKEDITOR.replace 接受ID和本土元素的实例。但是你要jQuery对象传递给它 - 它不能正常工作

您应该尝试这种方式:

  $(文件)。就绪(函数(){
    $('.ckeditor')。每个(函数(){
        CKEDITOR.replace(本);
    });
});

或者,如果你知道,这里有一个的textarea 来代替:

  $(文件)。就绪(函数(){
    CKEDITOR.replace($('.ckeditor')[0]);
});

查看的jsfiddle

这个例子

Is it possible to enable ckeditor by class type? For example, I tried the following code but getting error:

$(document).ready(function() {
    var txtArea= $(".ckeditor");   
    CKEDITOR.replace(txtArea,{ }); 
});

解决方案

CKEDITOR.replace accepts ids and native element instances. But you're trying to pass jQuery object to it - it cannot work.

You should try this way:

$( document ).ready( function() {
    $( '.ckeditor' ).each( function() {
        CKEDITOR.replace( this );
    } );
} );

Or, if you know that there's just one textarea to be replaced:

$( document ).ready( function() {
    CKEDITOR.replace( $( '.ckeditor' )[ 0 ] );
} );

See this example on JSFiddle.

这篇关于如何在asp.net中使用CKEditor的按类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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