2012-09-06 55 views
0

我使用.net框架4.0與MVC。HtmlBox(jQuery插件)不工作在Ajax調用

我在我的頁面中包含了HTMLBox(jquery插件),因爲我需要我的文本區域控件的WYSWYG編輯器。

我有一個稱爲指令的局部視圖,我申報的textarea的控制爲:

@Html.TextAreaFor(model => model.Instruction, new {@cols = 80, @rows = 10 }) 

在一個Ajax調用我填充我的網頁上這個局部視圖。就像這樣:

function EditInstruction(progId) 
    { 
      var getUserUrl = '@Url.Action("")'; 
      var courseType = $('input:radio[name=CourseType]:checked').val(); 
      var acadYr = $("#AcadYear").val(); 
      var sem = $("#Sem").val(); 

      $.ajax({ 
       url: '@Url.Action("EditInstruction", "CustomizeInstructionsAndCheckList")', 
       data: { progId: progId, acadYr: acadYr, sem: sem, courseType: courseType }, 
       cache: false, 
       type: "get", 
       // callback handler that will be called on success 
       success: function (response, textStatus, jqXHR) { 

       $("#PartailLoadForCheckList").html($(response)); 
       callAjaxCallsForCascade(getUserUrl.toString()); 
       TextEditorForDisplay(); 


       }, 
       // callback handler that will be called on error 
       error: function (jqXHR, textStatus, errorThrown) { 

       }, 
       // callback handler that will be called on completion 
       // which means, either on success or error 
       complete: function() { 

       } 
      }); 
     } 

This is the code for TextEditorForDisplay(), where I initialize my HtmlBox 

function TextEditorForDisplay() { 

     mybox = $("#Instruction").htmlbox({ 
     toolbars:[ 
     [ 
     // Cut, Copy, Paste 
     "separator","cut","copy","paste", 
     // Undo, Redo 
     "separator","undo","redo", 
     // Bold, Italic, Underline, Strikethrough, Sup, Sub 
     "separator","bold","italic","underline","strike","sup","sub", 
     // Left, Right, Center, Justify 
     "separator","justify","left","center","right", 
     // Ordered List, Unordered List, Indent, Outdent 
     "separator","ol","ul","indent","outdent", 
     // Hyperlink, Remove Hyperlink, Image 
     "separator","link","unlink","image"  
     ], 
     [// Show code 
     "separator","code", 
     // Formats, Font size, Font family, Font color, Font, Background 
     "separator","formats","fontsize","fontfamily", 
     "separator","fontcolor","highlight", 
     ] 
     ], 
     icons: 'default', 
     skin: 'blue', 
     success: function() { alert("Successfully posted"); }, 
     error: function() { alert("Error posting"); } 
     }); 



    } 
The problem I face is that, the HtmlBox works only when it is Loaded first and does not work for the subsequent ajax calls. 

這是錯誤我得到:TypeError: d.iframe.contentWindow is null

誰能幫助我在這?

感謝

+0

這是我的錯誤, 類型錯誤:d.iframe.contentWindow是nul1 –

回答

0

TinyMCE.MVC

MVC部分編輯模板,TinyMCE的HTML文本編輯器

PM> Install-Package TinyMCE.MVC

[UIHint("tinymce_jquery_full"), AllowHtml] 
public string Instruction { get; set; }