cheditor 자동 줄 늘리기 > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

cheditor 자동 줄 늘리기 정보

cheditor 자동 줄 늘리기

본문

글쓰기시 에디터가 창길이 자동으로 조정.
에디터 사용시 글 입력시 자동으로 늘어 나게 하는 함수 입니다

textarea에 text-overflow:ellipsis를 이용하시면 자동늘어나는데

에디터 같은경우는 iframe 을 써서 자동으로 늘어나기 힘들지요.

먼저 에디터있는곳에 아래은 스크립트를 넣어 주십니다
wr_content 는 각 에디터 이름이니 바꾸시면 됩니다
min_height 최소 높이 입니다
jQuery 에서
ie 에서는 div 로 값이 나오는데
나머지 브라우저에서는 p로 되야 값이 나옵니다

//------------------------------------
function checker()
{
var min_height = 210;
var height = 0 ;
jQuery("#wr_content_td iframe").contents().find("body > div").each(function (){
height += jQuery(this).height();
});
jQuery("#wr_content_td iframe").contents().find("body > p").each(function (){
height += jQuery(this).height();
});
if(height > min_height)
{
jQuery("#wr_content_td iframe").height(height+40);
}
else
{
jQuery("#wr_content_td iframe").height(min_height+40);
}
}

그리고 cheditor5/cheditor.js 을 여시고 doOnkeyUp 을 찾으신후
아래와 같이  parent.checker(); 를 넣어 주십니다

doOnKeyUp : function () {
//------------------
//줄변환 함수
parent.checker();
//------------------
    this.config.keyUpCount++;
},

글자 입력시 높이를 변경이 됩니다
추천
1
  • 복사

댓글 1개

© SIRSOFT
현재 페이지 제일 처음으로