一個頁面實例化兩個ueditor編輯器,同樣的出生卻有不同的命運


今天遇到一個比較怪異的問題,有一項目需要在同一個頁面上展現兩個ueditor編輯器,在展現時並不任何問題,但當點擊了“保存”按鈕時就出錯了,有其中一個ueditor在asp.net中無法獲取編輯器的值,這時代碼是這樣的:

 

//第一個ueditor 
<script type="text/plain" id="editorValue"><asp:Literal ID="ltlContent" runat="server"></asp:Literal>
</script>


//第二個ueditor
<script type="text/plain" id="editorContact" ><asp:Literal ID="ltlContact" runat="server"></asp:Literal>
</script>


//實例化 
<script type="text/javascript">
          var ue = new UE.ui.Editor({} );
          var ueContact = new UE.ui.Editor({} );
          ue.render( 'editorValue' );   
          ueContact.render( 'editorContact' );   
 </script>        

 結果就是editorContact這個編輯器的內容無法通過Request.Params["editorContact"]  去獲取內容,但第一個ueditor卻是正常的,為什么?代碼是一樣的,只是名字不一樣而已難道是同樣的出身竟有不同的命運?

 

~~~~~

我嘗試着改改id的名字問題依然是無法獲取編輯器的內容,最后我在第二個編輯器ueditor中加入一個屬性這問題竟然就解決了。:(

 

方式就是:

在第二個百度編輯器增加name屬性

 

最終代碼:

//第一個沒有name屬性的
<script type="text/plain" id="editorValue"><asp:Literal ID="ltlContent" runat="server"></asp:Literal>
</script>

//第二個有name屬性的ueditor
<script type="text/plain" id="editorContact" name="editorContact"><asp:Literal ID="ltlContact" runat="server"></asp:Literal>
</script>

 

竟然在代碼世界里也有這樣的不公待遇,真是一頭霧水啊~~~

 

----------------

原文鏈接:http://www.cnblogs.com/samlin/p/editor_without_name_attribute.html

 

@小小推廣--->

同時您也可以查看作者最近的項目 八爪魚招標網 大家多給意見哦 :)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM