私はブログを作成しています。ユーザーはブログでコメントできます。だから私はすべてのコメントとckeditorのブログ記事ごとのテキストエリアを表示するforeachステートメントを作った。今、奇妙なことはすべてうまく動作しますが、ckeditorは最初のブログでのみ動作し、textareasはすべてのブログで表示されます。ckeditorはforeach文で一度しか表示されませんasp.net mvc
これはwebinspectorエディタインスタンス「editor1」が既に設けられた素子に取り付けられ
キャッチされない示すエラーです。
はここに隠されたクラス名を持つdiv要素に
IEnumerable<Portfolio.Models.Messages>
@{
ViewBag.Title = "Home Page";
}
<script src="~/Scripts/Comments.js"></script>
<link rel="stylesheet" type="text/css" href="~/Content/css/Blog.css" />
@*Shows the blog posts that are posted to the database*@
@foreach (var messages in Model)
{
<div class="jumbotron opacity_container">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
@*Gets the title of the blog post*@
<h2 class="panel-title">
@messages.Title
</h2>
@messages.WhenCreated
</div>
@*Gets the body of the blog post and decodes the html of the
ckeditor*@
<div class="panel-body">
@Html.Raw(System.Web.HttpUtility.HtmlDecode(messages.Body))
</div>
</div>
</div>
@*this button gets the id from the database of the Message table
this helps to prevent that all the comments from all blogs gets
shown and thusshows only the comments that belong to the blog in
question*@
<button class="btn btn-primary" id="@messages.MessagesId"
onclick="ShowComments(this.id)">
Show Comments
</button>
@*this is the container where al the comments are placed in and
where you can post comments. The comments are placed in the Comment
partial view*@
<div class="hidden" id="[email protected](messages.MessagesId)">
@Html.Partial("_Comment")
@*this button gets the id from the database of the Message table
this helps to prevent that all the comments from all blogs gets
hidden and thushides only the comments that belong to the blog in
question*@
<button class="btn btn-primary" id="@messages.MessagesId"
onclick="HideComments(this.id)">
Hide Comments
</button>
</div>
</div>
}
partialviewと呼ばれる私の見解です。
これはCKEditorバージョンは、foreachループの内側に配置されている部分図の内部に配置され、私の部分図
@model IEnumerable<Portfolio.Models.Messages>
@{
ViewBag.Title = "Home Page";
}
<link rel="stylesheet" type="text/css" href="~/Content/css/Blog.css" />
<script src="~/Scripts/ckeditor/ckeditor.js"></script>
<div class="row" id="CommentContainer">
<div class="col-md-12">
<h3>Post Comment</h3>
@*The form to post comments*@
@using (Html.BeginForm("Create", "Messages"))
{
<div class="form-group">
<label>Comment</label>
@Html.TextArea("editor1", htmlAttributes:
new { name = "editor1",
id = "editor1", rows = "10", cols = "180" })
</div>
<button type="submit" class="btn btn-primary"
id="PostButton">Post Comment
</button>
}
@*CKEditor script*@
<script>
CKEDITOR.replace('editor1');
</script>
<div class="row">
<div class="col-md-10">
@*Places al the comments and decodes the html from the
ckeditor*@
@foreach(var messages in Model)
{
<div class="well" id="CommentBox">
@Html.Raw(System.Web.HttpUtility.HtmlDecode
(messages.Body))
</div>
}
</div>
</div>
</div>
</div>
あります。だから私が得意でないのは、税務署がすべての投稿では見えますが、ckeditorは同じforeachステートメントの中にあるのです。
すべてのCKEditorは同じID(editor1)を持っていますか?それぞれの固有のIDを生成するようにしてください –
Thnxは実際には解答です – ruinerwarrior