2013-04-09 49 views
4

下面是一個代碼nicEdit textarea的默認值

<?php 
if (isset($_POST['flag'])) { 

    $length=strlen(trim($_POST['area'])); 
    echo "Length of abstract : ".$length; 
    if (!strlen(trim($_POST['area']))){ 
     $abstractErrorMsg = "Please enter the abstract of your article"; 
     echo $abstractErrorMsg; 
    } 
} 
?> 
<form method="post" action=""> 
     <input type="hidden" name="flag" value="hidden"> 
     <script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> 
     <script type="text/javascript"> 
          //<![CDATA[ 
          bkLib.onDomLoaded(function() { 
           nicEditors.editors.push(
             new nicEditor().panelInstance(
             document.getElementById('myNicEditor') 
             ) 
             ); 
          }); 
          //]]> 
         </script> 

         * Abstract 

           <textarea name="area" id="myNicEditor" style="width: 300px;height: 100px;"></textarea> 

     <input type="submit" name="btn"> 
    </form> 

如果我提交形式,而無需輸入任何文本nicedit textarea的,它顯示長度= 4。 爲什麼是這樣?是否有默認值的nicedit textarea?如果是的話,如何改變它?

+0

這真的是原始碼嗎?我假設你在'textarea'標籤之間有一些空格字符... – CBroe 2013-04-09 08:45:48

+0

不,標籤之間沒有一個空格。它是一個原始代碼。 – 2013-04-09 08:51:19

回答

4

通過評論3條線解決問題。在niceEdit.js中搜索下面的代碼。默認情況下,它包含一個<br />

init : function() { 
      this.elm.setAttribute('contentEditable','true');  
      //if(this.getContent() == "") { 
      // this.setContent('<br />'); 
      //} 
      this.instanceDoc = document.defaultView; 
+0

我使用nicEdit-latest.js – 2013-04-09 08:56:24

+0

我從他們的網站上下載了今天下載的niceEdit.js文件的開發者版本的答案中的代碼。 (版本0.9 r24於2012年6月7日發佈) – 2013-04-09 09:00:26

+0

使用nicEdit.js textarea不加載所有的feactures.It只加載font-family,font-format和font-size。我想要全部。 – 2013-04-09 09:15:15