CKEditor的和ASP.Net MVC RequiredAttribute标签3 [英] CKEditor and ASP.Net MVC 3 RequiredAttribute

查看:102
本文介绍了CKEditor的和ASP.Net MVC RequiredAttribute标签3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经整合CKEditor的3(原FCKEditor的)到我的asp.net MVC(V3是具体的)应用程序。我有一个在RequiredAttribute标签我的模型,需要编辑,但客户端验证不CKEditor的正常工作领域。当我尝试提交我已经输入的数据到CKEditor的所需的验证不会看到的数据。如果我再次尝试重新提交,那么它的工作原理。我在网上看了看四周,找不到解决办法。我还使用jQuery和使用jQuery适配器

I've integrated CKEditor 3 (formerly FCKEditor) into my asp.net MVC (v3 to be specific) application. I have a RequiredAttribute in my model for the field that needs the editor but the client side validation doesn't work correctly with CKEditor. When I try to submit and I've entered data into CKEditor the required validation doesn't see the data. If I try resubmitting again, then it works. I've looked around online and can't find a solution. I am also using Jquery and using the Jquery adapter

<一个href=\"http://docs.cksource.com/CKEditor_3.x/Developers_Guide/jQuery_Adapter\">http://docs.cksource.com/CKEditor_3.x/Developers_Guide/jQuery_Adapter

推荐答案

如果有人正在寻找一种更通用的方式来做到这一点,你可以添加这个JavaScript:

If someone is looking for a more generic way to do this you can add this javascript :

    $(document).ready(function () {
    if ($('.text-editor')) {
        $('.text-editor').ckeditor();
        $('input[type=submit]').bind('click', function() {
            $('.text-editor').ckeditorGet().updateElement();
        });
    }
    });

和使用上一个textarea的.text编辑器CSS类和它的作品就好了。

And use .text-editor css class on a textarea and it works just fine.

@Html.TextAreaFor(model => model.Description, new { @class = "text-editor" })

我觉得这个解决方案eazyer比另一个,希望它能帮助!

I find this solution eazyer than the other one, hope it can helps!

这篇关于CKEditor的和ASP.Net MVC RequiredAttribute标签3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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