Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery拼写检查器如何访问页面上的文本框_Jquery_Spell Checking - Fatal编程技术网

jquery拼写检查器如何访问页面上的文本框

jquery拼写检查器如何访问页面上的文本框,jquery,spell-checking,Jquery,Spell Checking,我正在使用和实现如下 CKEDITOR.plugins.add('jqueryspellchecker', { config: { lang: $('.cul').val, parser: 'html', disableNativeSpellChecker : false, webservice: { path: '/JQuerySpellCheckerHandler.ashx', driver: 'google'

我正在使用和实现如下

CKEDITOR.plugins.add('jqueryspellchecker', {    
    config: {
        lang: $('.cul').val,
    parser: 'html',
    disableNativeSpellChecker : false,
    webservice: {
      path: '/JQuerySpellCheckerHandler.ashx',
      driver: 'google'
    },
    suggestBox: {
      position: 'below',
      appendTo: 'body'
    },
    incorrectWords: {
        container: '#incorrect-word-list'
    }
  },

  init: function( editor ) {

    var t = this;
    var pluginName = 'jqueryspellchecker';

    this.config.suggestBox.position = this.positionSuggestBox();

    editor.addCommand(pluginName, {
      canUndo: false,
      readOnly: 1,
      exec: function() {
        t.toggle(editor);
      }
    });

    editor.ui.addButton('jQuerySpellChecker', {
      label: 'SpellCheck',
      command: pluginName
    });

    editor.on('saveSnapshot', function() {
      t.destroy();
    });
  },

  create: function() {
    this.createSpellchecker();
    this.editor.setReadOnly(true);
    this.spellchecker.check();
    this.editor.commands.jqueryspellchecker.toggleState();
  },

  destroy: function() {
    if (!this.spellchecker) 
      return;
    this.spellchecker.destroy();
    this.spellchecker = null;
    this.editor.setReadOnly(false);
    this.editor.commands.jqueryspellchecker.toggleState();
  },

  toggle: function(editor) {
    this.editor = editor;
    if (!this.spellchecker) {
      this.create();
    } else {
      this.destroy();
    }
  },

  createSpellchecker: function() {
      var t = this;

    t.config.getText = function () {
      //alert(t.editor.getData());
      //alert($(t.editor.container).attr("data-code"));      
      return $('<div >').append(t.editor.getData()).text();
    };

   // t.spellchecker = new $.SpellChecker($(t.editor.container), this.config);
    t.spellchecker = new $.SpellChecker('.cke_focus', this.config);
    t.spellchecker.on('check.success', function () {
      alert('There are no incorrectly spelt words.');
      t.destroy();
    });

    t.spellchecker.on('replace.word', function () {
      if (t.spellchecker.parser.incorrectWords.length === 0) {
        t.destroy();
      }
    });
  },

  positionSuggestBox: function() {

      var t = this;

    return function() {

      var ed = t.editor;
      var word = (this.wordElement.data('firstElement') || this.wordElement)[0];

      var p1 = $(ed.container.$).find('.cke_focus').offset();
      var p2 = $(ed.container.$).offset();
      var p3 = $(word).offset();

      var left = p3.left;
      var top = p3.top + word.offsetHeight;      

      this.container.css({ 
        top: top, 
        left: left  
      });
    };
  }
});
CKEDITOR.plugins.add('jqueryspellchecker',{
配置:{
朗:$('.cul').val,
语法分析器:“html”,
DisablentiveSpellChecker:false,
网络服务:{
路径:'/JQuerySpellCheckerHandler.ashx',
司机:“谷歌”
},
建议框:{
位置:'下方',
附:“身体”
},
不正确的词语:{
容器:“#单词列表不正确”
}
},
init:函数(编辑器){
var t=这个;
var pluginName='jqueryspellchecker';
this.config.suggestBox.position=this.positionSuggestBox();
editor.addCommand(pluginName{
canUndo:错,
只读:1,
exec:function(){
t、 切换(编辑器);
}
});
editor.ui.addButton('jQuerySpillChecker'{
标签:“拼写检查”,
命令:pluginName
});
on('saveSnapshot',function()){
t、 破坏();
});
},
创建:函数(){
这个.createSpellchecker();
this.editor.setReadOnly(true);
this.spellchecker.check();
this.editor.commands.jqueryspellchecker.toggleState();
},
销毁:函数(){
如果(!this.spellchecker)
返回;
this.spellchecker.destroy();
this.spellchecker=null;
this.editor.setReadOnly(false);
this.editor.commands.jqueryspellchecker.toggleState();
},
切换:函数(编辑器){
this.editor=editor;
如果(!this.spellchecker){
这个。create();
}否则{
这个。销毁();
}
},
createSpellchecker:函数(){
var t=这个;
t、 config.getText=函数(){
//警报(t.editor.getData());
//警报($(t.editor.container).attr(“数据代码”);
返回$('').append(t.editor.getData()).text();
};
//t.spellchecker=new$.spellchecker($(t.editor.container),this.config);
t、 spellchecker=new$.spellchecker('.cke_focus',this.config);
t、 拼写检查器.on('check.success',函数(){
警惕(“没有拼写错误的单词”);
t、 破坏();
});
t、 拼写检查器.on('replace.word',函数(){
if(t.spellchecker.parser.incorrectWords.length==0){
t、 破坏();
}
});
},
positionSuggestBox:函数(){
var t=这个;
返回函数(){
var-ed=t.editor;
var word=(this.wordElement.data('firstElement')| | this.wordElement)[0];
var p1=$(ed.container.$).find('.cke_focus').offset();
变量p2=$(ed.container.$).offset();
var p3=$(word.offset();
var left=p3.left;
var-top=p3.top+word.offsetHeight;
这个.container.css({
顶:顶,,
左:左
});
};
}
});
但是如何在页面上获取文本框的值以设置语言..
lang:$('.cul').val


谢谢

CKEDITOR插件可以使用编辑器.name属性访问当前实例id。 然后使用$('#'+editor.name)将为您提供当前CKEDITOR的目标textarea

您正在编写CKEDIOR插件,因此,与其采用单独的方式设置文化,不如将其作为目标textarea的一部分。在那里,您可以设置基于HTML5的数据属性,如数据区域性,这将为目标RichTextbox提供所需的区域性


在某些业务场景中,一个页面可能会有多个RichTextBox控件,每个控件都具有不同的文化背景,如在线谷歌翻译器页面。

您能告诉我您需要哪个文本框吗?为什么?文本框是带有class.cul的文本框,要从该文本框中获取语言值,我需要动态设置语言,默认情况下,每个页面的语言不同,您可以设置lang:'en'或其他任何语言。然后在“init”中,您可以获得正确的区域性值并将其设置在那里。