2013-02-15 4 views
0

joomla를 사용하여 joomla 기본 텍스트 편집기의 흐림 효과를 확인하는 방법?joomla 2.5 기본 텍스트 편집기를 확인하는 방법?

이것은 텍스트 편집기를 사용하는 코드입니다. 예, /models/forms/newsitem.xml에서 :

<field name="description" type="editor" buttons="true" 
        hide="pagebreak,readmore,article,image" 
        class="inputbox required" 
        filter="JComponentHelper::filterText" 
        label="JGLOBAL_DESCRIPTION" 
        description="COM_NEWSITEMS_FIELD_DESCRIPTION_DESC" required="true" /> 

그리고 두 번째 파일 (/views/.../edit.php) - 새로운 기능 객체는 자바 스크립트에 추가 할?

<script type="text/javascript"> 
    Joomla.submitbutton = function(task) { 
     if (task == 'newsitem.cancel' || document.formvalidator.isValid(document.id('newsitem-form'))) { 
      <?php echo $this->form->getField('description')->save(); ?> 
      Joomla.submitform(task, document.getElementById('newsitem-form')); 
     } else { 
      alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>'); 
     } 
    } 
</script> 

내가 원하는 것은 텍스트 편집기 옆에 "이 비워 둘 수 없음"이라는 경고 메시지를 표시하려고합니다. 양식을 제출할 때도 할 수 있지만 실제 문제는 흐리게 처리하는 방법입니다. 전용 편집기는 this-

jQuery('#editorid').blur(function() { 
    if(!document.formvalidator.isValid(document.id('newsitem-form'))){ 
    //Add your error message code 

    } 
}); 

업데이트 시도 할 수있는 형태로 존재하는 경우

답변

0

나는 그것을 얻었습니다. 변경된 답변 (로그인 -Irfan).하지만 "저장"을 클릭하면 편집기에 오류 (빈 텍스트)가 표시됩니다. 여기에 한 예가 있습니다 :

<script type="text/javascript">  
    Joomla.submitbutton = function(task) { 
     if (task == 'newsitem.cancel' || document.formvalidator.isValid(document.id('newsitem-form'))) { 
      if(task != 'newsitem.cancel') { 
      var boolSubmit = true; 
      if(jQuery('#jform_description_parent').is(':visible')) { 
       jQuery(jQuery('#jform_description_parent iframe')[0].contentWindow).each(function() { 
        var editor_text = jQuery('#jform_description_parent iframe').contents().find('body').text(); 
        if(editor_text=='') { 
         alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>'); 
         boolSubmit = false 
        } 
       }); 
      } else { 
       jQuery('textarea#jform_description').each(function() { 
        if(jQuery(this).val()=='') { 
         alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>'); 
         boolSubmit = false; 
        } 
       }); 
      } 
      if(!boolSubmit) 
       return boolSubmit; 
      } 
      <?php echo $this->form->getField('description')->save(); ?>    
      Joomla.submitform(task, document.getElementById('newsitem-form')); 
     } else { 
      alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>'); 
     } 
    } 
</script> 

모두 올바른 결론? 나는 그것이 좋을지도 모른다라고 생각한다.

0

이 코드 document.formvalidator.isValid(document.id('newsitem-form'))는 양식의 유효성을 확인 : -

jQuery(jQuery('iframe')[0].contentWindow).blur(function() { 
var editor_text = jQuery('iframe').contents().find('body').text(); 
if(editor_text=='')alert('Error message'); 
}); 

참고 : 올바른 선택 -use 그 에디터가 iframe을 가리키고 있는데 이것은 편집기가 하나만있는 경우에만 작동합니다.

희망이 도움이 될 것입니다.

+0

안녕하세요, Irfan. 불가능하다. 오류 출력이 없습니다. 예를 들어, $ ('# jform_description')을 작성했습니다. blur ... 그러나 XML의 클래스 (관리자의 편집기)에는 'required'가 표시되지 않습니다. 도와주세요. 나는해야한다. 나는 너의 대답을 기다리고있다 –

+0

나는 말하기 깜빡했다. 그것은 설치되었습니다 JCE –

+0

@Areku_UA : 나는 내 대답을 업데이트했습니다 이것이 당신을 안내 할 것입니다. – Irfan