富文本编辑器和按提交焦点按钮 [英] Rich Text Editor and focus by submit button

查看:234
本文介绍了富文本编辑器和按提交焦点按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与 Rich Text Editor 相关联的文本区域.我已经按照步骤安装它,并且一切运行顺利.有问题的文本区域在一个表单中,其中包含其他文本区域和要填写的字段.单击经典的提交按钮,我通过js进行了设置,如果该字段为空,则会出现警报,并且系统会将焦点放在空元素上.

I have a textarea to which I associate a Rich Text Editor. I've followed the steps to install it and everything runs smoothly. The textarea in question is within a form with other textarea and fields to be filled out. Clicking on the classic submit button, I set via js that if the field is empty an alert appears and the system puts the focus on the empty element.

这不适用于与富文本编辑器结合使用的文本区域,显然是因为后者将其转换为某种框架...

This does not work with the textarea combined with the Rich Text Editor, obviously because the latter transforms it into a sort of frame ...

我使用CLEditor WYSIWYG Editor作为编辑器:

<html>
<head>
<link rel="stylesheet" href="jquery.cleditor.css" />
<script src="jquery.min.js"></script>
<script src="jquery.cleditor.min.js"></script>
<script>
    $(document).ready(function () { $("#nomexf").cleditor(); });
</script>
</head>
<body>
<textarea id="nomexf" name="nomexf"></textarea>
</body>
</html>

我试图以几种不同的方式解决我的问题,例如:

I've tried to solve my problem in a few different ways, for example:

function checkForm(form) {      
    if(form.nomexf.value == "") {
      alert("Il campo Titolo non è stato compilato!");
       $("#nomexf").cleditor().focus();
      return false;
    }
}

但是,我仍在努力使其正常工作.

However, I am still struggling to make it work.

推荐答案

cleditor()返回一个数组,因此您必须指定所需的文本区域:

cleditor() returns an array so you have to specify which textarea you want:

尝试一下:

$('#nomexf').cleditor()[0].focus();

这篇关于富文本编辑器和按提交焦点按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆