如何使TinyMCE和Jquery验证可以一起工作? [英] How to get TinyMCE and Jquery validate to work together?

查看:105
本文介绍了如何使TinyMCE和Jquery验证可以一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery validate和tinymce的jquery版本.

I am using jquery validate and the jquery version of tinymce.

我发现这段代码使tinymce每次发生更改时都可以进行自我验证.

I found this piece of code that makes tinymce to validate itself every time something changes in it.

我正在将jquery validatem与我的jquery tinymce一起使用,因此我将其包含在我的代码中

I am using the jquery validate with my jquery tinymce so I have this in my code

    // update validation status on change
    onchange_callback: function (editor)
    {
        tinyMCE.triggerSave();
        $("#" + editor.id).valid();
    },

这有效,但是存在一个问题.如果用户从单词中复制了某些东西,它将带来所有垃圾样式,通常超过50,000个字符.这超出了我允许用户输入的字符数.

This works however there is one problem. If a user copies something from word it brings all that junk styling with it what is usually over 50,000 characters. This is way over my amount of characters a user is allowed to type in.

所以我的jquery验证方法告诉我它们超出了限制.同时,尽管tinymce清理了混乱的情况,但现在用户有可能没有超过限制.

So my jquery validation method goes off telling me that they went over the limit. In the mean time though tinymce has cleaned up that mess and it could be possible now the user has not gone over the limit.

消息仍然存在.

那么有没有更好的函数可以调用呢?也许告诉tinymce在粘贴发生时延迟有效时间,或者告诉其他回调?

So is there a better function call I can put this in? Maybe tell tinymce to delay the valid when a paste is happening, or maybe a different callback?

有人有什么主意吗?

推荐答案

哦,是的,我也遇到了这个问题.

Oh yeah, I also faced this problem.

因此,我通过在按钮的click事件上调用验证来解决此问题.

So, I fixed it by calling the validation on the click event of a button instead.

$("#buttontosave").click(function() {
         tinyMCE.triggerSave();
         var status;
         status = $("#myform").valid(); //Validate again
         if(status==true) { 
             //Carry on
         }
         else { }
});

这可以尝试一下.

有关其他资源,请尝试

http://rmurphey.com/blog/2009/01/12/jquery-validation-and-tinymce/

http://tinymce.moxiecode.com/punbb/viewtopic.php ?id = 21588

http://www.experts-exchange .com/Programming/Languages/Scripting/JavaScript/Jquery/Q_23941005.html

这篇关于如何使TinyMCE和Jquery验证可以一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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