2014-09-11 6 views
0

웹 사이트에 텍스트 영역이 너무 많습니다.주어진 ID로 하나의 텍스트 영역을 제외하고 allTextAreas에서 nicEdit을 활성화하는 방법은 무엇입니까?

나는이 instanciation 모든 텍스트 영역에 nicEdit의 위지윅 (WYSIWYG) HTML 편집기를 가능하게하고있다 :

<script type="text/javascript"> 
bkLib.onDomLoaded(nicEditors.allTextAreas); 
</script> 

은 내가 id="noeditor"와 텍스트 영역에 그것을 사용하지 않으려는.

고맙습니다.

+0

은 "nicEditors.allTextAreas"배열입니까? – Mike

답변

0

또한 문제가 있지만 jquery를 사용하여 해결했습니다. 그냥 당신이 제외 할 텍스트 영역에 클래스 ne-except를 추가하려면이

bkLib.onDomLoaded(function() { 
    nicEditors.allTextAreas(); 
    jQuery('.ne-except').each(function(){ 
     $parent = jQuery(this).parent(); 
     $parent.children('div').hide(); 
     $parent.children('textarea').show(); 
    }); 
}); 

bkLib.onDomLoaded(nicEditors.allTextAreas); 

을 컨테이너에 텍스트 영역을 넣고 교체합니다.

을 heres 내 바이올린 : http://jsfiddle.net/gozonjoedaimar/9y933f1c/6/

업데이트 : 이 방법을 사용하여 폼 내부의 텍스트 영역은 텍스트 영역의 가치를 게시하지 않는 것을 발견. div.nicEdit-main 내부의 값을 사용합니다. 이 문제를 해결하려면 아래 코드를 사용하십시오.

bkLib.onDomLoaded(function() { 
    nicEditors.allTextAreas(); 

    jQuery('.ne-except').each(function(){ 
     jQuery(this).prev().prev().hide(); 
     jQuery(this).prev().hide(); 
     jQuery(this).on('keyup',function(){ 
      jQuery(this).prev() 
       .find('.nicEdit-main') 
       .html(jQuery(this).val()); 
     }); 
     jQuery(this).show(); 
    }); 
}); 

또한 div 요소에 의존하는 이전 솔루션과는 달리 코드가 독립적으로 업데이트되었습니다.