2017-01-19 43 views
0

在mvc項目中爲我的textarea編輯器使用nicEditor時出現問題。NicEditor在mvc中無法正常工作

這裏是我有created.From的第一視圖2視圖頁面我傳遞路由值給第二視圖

<ul class="mar"> 

      @foreach (var item in Model) 
     { 
       <li class="mar" style="list-style-type:none"> 
        <div style="display:inline-block;font-size:small"> 

          <a id="[email protected]" class="glyphicon glyphicon-triangle-right" style="text-decoration:none;cursor:pointer;color:dimgray" onclick="toggle(@item.thread.MessageID)"></a> 
         <h3 class="mar" style="display:inline-block;"><a href="@Url.Action("GetMessage", "Home", routeValues: new{id=thread.Title.MessageID})" style="text-decoration:none;cursor:pointer">@item.thread.Title</a></h3> 
        </div> 
     <li> 
     </ul> 

第二個視圖

@Scripts.Render("~/bundles/jquery") 
<script type="text/javascript" src="~/Scripts/nicEdit.js"></script> 
<script type="text/javascript"> 
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() }); 
</script> 
     <h2>GetMessage</h2> 
     <textarea style="width:900px"></textarea> 

這裏第二視圖顯示niceditor( textarea)沒有它的圖像inEdild與nicEditor enter image description here

當我從第一視圖中刪除傳遞參數,然後它工作正常..

enter image description here

我需要知道爲什麼會發生這樣的???

回答

0

使用瀏覽器的開發人員工具並觀察網絡視圖,nicEditoricons.gif未加載的原因是路徑問題。使用選項iconsPath來設置正確的一個。 請看看niceit手冊。

var NicEditconfig = { 
    iconsPath : '/img/nicEditorIcons.gif', 
    buttonList : ['bold','italic','underline','ol','ul'] 
}; 
+0

是的,圖像節點上有404錯誤。但不知道原因。我在.js文件中找到了上面的代碼。它就像var NicEditorconfig = { iconsPath:'../nicEditorIcons.gif', buttonList:['bold','italic','underline','ol','ul'] };我該如何解決問題? –

+0

http://nicedit.com/demos.php?demo=2 – nevtag

0

您需要配置的路徑手動

首先,檢查控制檯找到當前請求的路徑。如果請求路徑是錯誤的,然後將其配置 HTML

<textarea id="textAreaNiceEditor" style="width: 100%;"> 
     Some Initial Content was in this textarea 
    </textarea> 

JS代碼

<script src="~/Content/NiceEditor/nicEdit.js"></script> 
<script type="text/javascript"> 
    //<![CDATA[ 
    bkLib.onDomLoaded(function() { 
     new nicEditor({ iconsPath: '../../../Content/NiceEditor/nicEditorIcons.gif' }).panelInstance('textAreaNiceEditor'); 
    }); 
    //]]> 
</script> 

'../../../Content/NiceEditor/nicEditorIcons.gif'

根據您的gif位置更改此路徑值。

請確保您使用的是在JS代碼中使用相同的textarea id。以上情況的id值是textAreaNiceEditor