截止日期后jQuery textarea删除

时间:2011-02-09 21:18:54

标签: jquery coldfusion

我们公司最近转而使用After the Deadline作为拼写检查。我们喜欢它的功能,但是,我们基本上必须破解它,以便它可以在各个客户站点的每个页面上运行。长话短说,我最终使用jQuery在每个页面上应用拼写检查。

问题在于,当您检查拼写并完成拼写时,如果您提交拼写,则不会通过帖子传递表单字段。我们正在运行Coldfusion,它只是说表单变量不存在。

这是代码,它非常简单:

    function check(elId,linkId)
 {
    AtD.checkTextAreaCrossAJAX( elId , linkId, '<img src="http://www.curricunet.com/images/accept.png" />Finish Checking');
 };

我认为他们提供的jQuery插件有问题。 After the Deadline jQuery plugin。我一直在倾注他们的插件(在src文件夹中,他们有一个未经说明的版本。)我似乎无法找到问题。他们在这个网站上没有很好的支持。

你们能想出为什么会从表格中删除textarea吗?

这是我认为打破代码的功能(至少在Firefox和Chrome中):

AtD.restoreTextArea = function(id) {
    var options = AtD.textareas[id];

    /* check if we're in the proofreading mode, if not... then retunr */
    if (options == undefined || options['before'] == options['link'].html())
        return;

    /* clear the error HTML out of the preview div */
    AtD.remove(id);

    /* clear the AtD synchronization field */
    jQuery('#AtD_sync_').remove();

    /* swap the preview div for the textarea, notice how I have to restore the appropriate class/id/style attributes */

    var content;

    if (navigator.appName == 'Microsoft Internet Explorer')
        content = jQuery('#' + id).html().replace(/<BR.*?class.*?atd_remove_me.*?>/gi, "\n");
    else
        content = jQuery('#' + id).html();

    jQuery('#' + id).replaceWith( options['node'] );
    jQuery('#' + id).val( content.replace(/\&lt\;/g, '<').replace(/\&gt\;/, '>').replace(/\&amp;/g, '&') );
    jQuery('#' + id).height( options['height'] );

    /* change the link text back to its original label */
    options['link'].html( options['before'] );
};

1 个答案:

答案 0 :(得分:0)

在textareas http://www.polishmywriting.com/atd-jquery/demo2.html

上查看他们的演示

如果您查看Firebug中的渲染页面,当您单击拼写检查按钮时,textarea将替换为可编辑的div和带有生成ID的隐藏表单字段

<div contenteditable="true" id="textInput" style="height: 194px; overflow: auto; white-space: pre-wrap; outline: medium none; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-size: 16px; font-family: times; border: 1px solid rgb(0, 0, 0); text-align: start; margin: 2px; width: 394px; line-height: 20px; letter-spacing: normal; left: auto; right: auto; top: auto; bottom: auto; position: static; padding: 2px;" class="input" spellcheck="false">text</div>

<input type="hidden" id="AtD_sync_" value="The purpoce of a spell checker is to check the text four spelling and typeing errors. The checker finds errors througout the text. When the spell checker finds an questionable word, it highlights it and suggests the mpst likely variants too replace the questionable word. You can select the variant and replace the wrrd or leave the word unanged." name="">

是否提交表单而不重新点击拼写检查按钮(将其转回textarea)?这可以解释为什么POST上不存在该字段。您可能必须模拟转换回形式

的提交处理程序的逻辑