kindeditor tab + enter 提交 发送

http://www.notewo.com/archive/1

把kineditor 整合到我的网站 中,想绑定 tab +enter 提交发送,做法如下:

   var options = {  

            afterTab:function(e){
//用id 标识不同的submit button $(
"#submit_"+target_id).focus(); e.preventDefault(); }, }; editor = KindEditor.create('#'+content_id,options);

 

    
    $("#messageform_"+target_id).submit(function(){
        editor.sync();
        var options = { 
            success: function(response){
                editor.html('');
                editor.sync();
                editor.focus();
            }
        }
        $(this).ajaxSubmit(options);
        return false;
    });

但是,在ff 和opera 上就工作正常,在chrome上就不行。第一次tab + enter 之后,焦点重新回到editor ,再次tab + enter ,就没法把焦点定位到submit 的button 了。

但是我却发现个问题,把鼠标点一下页面其它地方,再点回editor ,再tab + enter ,就又可以了。囧~~~什么原因 。

所以解决办法就是:

        var options = { 
            success: function(response){
                editor.html('');
                editor.sync();
                //for chrome 
                //kindeidotr ,在ff 和opera 上面都工作正常,但是在chrome上,tab + enter 发送一次后就不正常了,解决方法是先把focus定位到其它元素,再定位回editor ,就可以了。
                $(".topic_inbox").focus();
                editor.focus();
            }
        }

加上红色那句就可以了。

不知道原因是什么 ~~~

 

posted @ 2013-01-09 14:30  notewo  阅读(372)  评论(0编辑  收藏  举报