CKEditor and ASP.Net MVC 3 RequiredAttribute

前端 未结 7 591
情深已故
情深已故 2020-12-08 15:56

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 edi

7条回答
  •  伪装坚强ぢ
    2020-12-08 16:10

    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();
            });
        }
        });
    

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

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

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

提交回复
热议问题