Abbas Foroughi
Abbas Foroughi

Reputation: 63

TinyMCE doesn’t work in MVC

Why TinyMCE doesn’t work when I use a class library in different project?

enter image description here

enter image description here

but when I put my class in the same project it works!

enter image description here enter image description here

How can I solve the problem?

Thanks

Upvotes: 0

Views: 161

Answers (1)

man_luck
man_luck

Reputation: 1656

Your MyLibrary library does not have access to the Editor Template while when you place the attribute in your View Model, the editor template is accessible. The second approach is the correct one as thats the model you are going to use in your view. You should not be using the entity model or a model in any class library in the view. Use tools like automapper to map view model to your entity model.

It will work if you remove the UIHINT attribute from the Product > Description property and make the Description field as the tinymce control like;

@Html.TextAreaFor(m => m.Description , new { @class = "form-control mceEditor" })

where mceEditor is the class you define while initializing tinymce object (presumably in your js file or the editor template, tinymce_jquery_full);

tinymce.init({
            mode: "specific_textareas",
            editor_selector : "mceEditor",
            height: 100,
            plugins: [
                "advlist autolink lists link charmap print preview anchor textcolor",
                "searchreplace visualblocks code fullscreen",
                "insertdatetime table contextmenu paste textcolor"
            ],
            toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | forecolor backcolor"
        });

Or just do the right way you have done in the second approach.

Upvotes: 2

Related Questions