jquery keyup对CKEDITOR中的数据 [英] jquery keyup on the data inside CKEDITOR

查看:285
本文介绍了jquery keyup对CKEDITOR中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个假的html / css手机,它自动从一个页面上的几个输入框中插入数据,如下所示:(手机插入使用iframe ..(不要问)..) / p>

I'm building a little fake html/css mobile phone which automatically inserts data from a several input boxes on a page like so: (the phone is inserted using an iframe..(don't ask)..)

$('#mgSiteDescription').bind('keyup', function() { 
   var iframedoc = $('.liveDemoFrame').get(0).contentDocument; 
   $(iframedoc).find('#header h2').html($(this).val()); 
});

这对我的输入字段绝对正常。

This works absolutely fine for my input fields.

现在,我使用CKEditor为我的文本区域,这使我的问题。由于textarea没有在页面上实时更新,我的keyup事件不工作,因此,不更新我的假电话。如何调整CKEditor以便更新隐藏的文本区域?或者甚至可以访问CKEditor的iframe并将数据拉出来?

Now, I'm using CKEditor for my textareas which brings me to my problem. As the textarea isn't being updated live on the page, my keyup event isn't working and therefore, not updating my fake phone. How can I adjust CKEditor so that it updates the hidden textarea? Or maybe even access CKEditor's iframe and pull that data out?

谢谢。

推荐答案

更新:

我已经设法通过CKEditor获得一个keyup函数,甚至删除了我的假手机iFrame的内容。我只是不知道如何插入CKeditor的值/数据到我的iframe..if有意义?

I've managed to get a keyup function working through CKEditor and it even removes the content from my fake mobile phone iFrame. I just don't know how to then insert the value/data of CKeditor into my iframe..if that makes sense?

    CKEDITOR.instances.mgAddHomePage.on('contentDom', function() {
        CKEDITOR.instances.mgAddHomePage.document.on('keyup', function(event) {

            var iframedoc = $('.liveDemoFrame').get(0).contentDocument; 
            $(iframedoc).find('#content').html($(this).val());      

        });
    });

这是我需要更新我猜猜吗?

It's this bit I need to update I'm guessing?

html($(this).val())

有什么想法?

编辑

我得到它工作足够接近我的意图。这里是对我有类似立场的任何人的最终代码:

So I got it working near enough to how I intended. Here's the final code for anyone in a similar position to me:

    CKEDITOR.instances.mgAddHomePage.on('contentDom', function() {
        CKEDITOR.instances.mgAddHomePage.document.on('keyup', function(event) {
            var iframedoc = $('.liveDemoFrame').get(0).contentDocument; 
            $(iframedoc).find('#content').html(CKEDITOR.instances.mgAddHomePage.getData());         
        });
    });

即使你没有使用iFrames,这仍然可以工作。只需要修改jquery iframe的东西。

Even if you're not using iFrames, that'll still work. Just hack out the jquery iframe stuff.

这篇关于jquery keyup对CKEDITOR中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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