为什么在我的CKEditor中需要双击“提交"按钮才能起作用? [英] Why in my CKEditor need to double click the submit button to work?

查看:114
本文介绍了为什么在我的CKEditor中需要双击“提交"按钮才能起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为管理内容"的模块,管理员可以在其中编辑网站的内容.我看到了此CKEditor,并将其应用于我的网站,但遇到了问题.当我单击提交时,它不会改变,但是当我尝试双击提交时,它会改变.

Im have a module called manage content where the admin can edit the content of the website. I saw this CKEditor and I applied it to my website, but having a problem. When I clicked the submit, it won't change but when I tried to double click the submit it will change.

查看

<div class="col-md-6">

          <ol class="breadcrumb">
          <div id="success-message-edit-about"></div>
          <form id="edit-about">
            <input type="hidden" name="id" value="<?= secret_url('encrypt',$edit_about->id)?>">
            <div class="form-group">
            <label>Content</label>

             <textarea  id="editor" rows="4" cols="50"  name="content_description" class="form-control"><?= $edit_about->content?></textarea>
                  <div class="text-danger" id="content_description_error"></div>
            </div>


            <input type="submit" class="btn btn-success " value="Continue" align="center" ">

          </form>


          </ol>
 </div>

JS

$(document).ready(function(){
    $("#edit-about").on('submit',function(e){
        $.ajax({
            url: base_url + "administrator/edit_about_form_submit",
            type: "POST",
            data: $(this).serialize(),

            success:function(data) {
                var result = JSON.parse(data);

                if(result === "success")
                {
                    $("h5").html("");
                    success_message("#success-message-edit-about","Thank you!");
                    window.setTimeout(function(){location.href=base_url+"administrator/about"},2000);
                }
                else{

                    $("#link_error").html(result.link_error);
                }
            },
            error: function(data) {
                alert('error');
            }
        })
        e.preventDefault();
    })
})

控制器

public function edit_about_form_submit() 
    {

        echo json_encode($_POST['content_description']);die;
    }

场景

Content: This is my content

Change into: Update Content

然后,当我单击提交"时,在我的检查元素中,它没有更改.但是当我双击提交时,它将立即更改.

Then when I click the submit, in my inspect element it didnt change. But when I double click the submit it will now change.

问题:我该如何解决?应该只单击一次,不要两次

Question: How can I fix this? It should be only once clicked not twice

JS

$(document).ready(function(){
    $("#edit-about").on('submit',function(e){
         for ( instance in CKEDITOR.instances )
         {
           CKEDITOR.instances[instance].updateElement();
           $.ajax({
            url: base_url + "administrator/edit_about_form_submit",
            type: "POST",
            data: $(this).serialize(),

            success:function(data) {
                var result = JSON.parse(data);

                if(result === "success")
                {
                    $("h5").html("");
                    success_message("#success-message-edit-about","Thank you!");
                    window.setTimeout(function(){location.href=base_url+"administrator/about"},2000);
                }
            },
            error: function(data) {
                alert('error');
            }
        })
        e.preventDefault();
         }

    })
})

推荐答案

我是从2012年论坛帖子中发现的.

I found this from a 2012 forum post.

http://forum.codeigniter.com/thread-51301.html

我的问题的解决方案是我必须在发帖之前致电给我 到服务器:

THE SOLUTION to my problem was that I had to call this before posting to the server:

代码:

 for ( instance in CKEDITOR.instances )
 {
   CKEDITOR.instances[instance].updateElement();
 }

这篇关于为什么在我的CKEditor中需要双击“提交"按钮才能起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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