ckeditor 和灯箱不工作 [英] Ckeditor and Lightbox not work

查看:20
本文介绍了ckeditor 和灯箱不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!我按照 http://ckeditor.com/addon/lightbox 指令完成了所有操作,但我一直都在制作此错误(按下按钮灯箱时):未捕获类型错误:无法读取未定义的属性拆分"

Good day! I did everything by this http://ckeditor.com/addon/lightbox instruction, but I have always produces this error (when press button lightbox): Uncaught TypeError: Cannot read property 'split' of undefined

代码:

<!DOCTYPE html>
<!--
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
-->
<html>
<head>
    <meta charset="utf-8">
    <title>Replace Textarea by Code &mdash; CKEditor Sample</title>
        <script src="../ckeditor.js"></script>
         <script src="../jquery-1.11.0.min.js"></script>
    <link href="sample.css" rel="stylesheet">
    <link rel="stylesheet" href="lightbox.css">
</head>
<body>
    <h1 class="samples">
        <a href="index.html">CKEditor Samples</a> &raquo; Replace Textarea Elements Using JavaScript Code
    </h1>
    <form action="sample_posteddata.php" method="post">
        <div class="description">
            <p>
                This editor is using an <code>&lt;iframe&gt;</code> element-based editing area, provided by the <strong>Wysiwygarea</strong> plugin.
            </p>
<pre class="samples">
CKEDITOR.replace( '<em>textarea_id</em>' )
</pre>
        </div>
        <textarea cols="80" id="editor1" name="editor1" rows="10">

        </textarea>
        <script>


            CKEDITOR.replace( 'editor1' );

        </script>
        <p>
            <input type="submit" value="Submit">
        </p>
    </form>
    <div id="footer">
        <hr>
        <p>
            CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
        </p>
        <p id="copy">
            Copyright &copy; 2003-2015, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
            Knabben. All rights reserved.
        </p>
    </div>
<script type="text/javascript">
$(document).ready(function(){ ckeLightbox(); });
function ckeLightbox(){
    var c=0;
    $('a.ckelightbox').each(function(){
        c++;
        var g=$(this).attr('class').split('ckelightboxgallery')[1];
        if(!g)g=c;
        $(this).attr('data-lightbox',g);
        $(this).attr('data-title',$(this).attr('title'));
    }); 
}
</script> 
</body>
</html>

所有脚本已加载 - http://take.ms/2Jnx8

您能否提供一个工作示例?

Could you please provide a working example?

这是我的测试项目 - http://take.ms/OJpKE

this is my test project - http://take.ms/OJpKE

推荐答案

我得到同样的错误.该插件不起作用.由于没有在 dialogs/lightbox.js 的第 20 行定义变量 gal (尽管这同样适用于第 21 和 22 行),因此发生此特定错误.但是,即使您检查未定义:

I get the same error. The plugin doesn't work. This particular error is happening due to the variable gal not being defined on line 20 of dialogs/lightbox.js (although the same would apply to lines 21 and 22). However, even if you check for undefined:

if(typeof gal !== 'undefined') {gal = gal.split("ckelightboxgallery");
gal = gal[1];
a.advanced && this.setValue(gal || ""); }

...它仍然不起作用.我很确定问题与这段代码有关:

...it still doesn't work. I'm pretty sure the problem has to do with this code:

<script>
$(document).ready(function(){ ckeLightbox(); });
function ckeLightbox(){
    var c=0;
    $('a.ckelightbox').each(function(){
        c++;
        var g=$(this).attr('class').split('ckelightboxgallery')[1];
        if(!g)g=c;
        $(this).attr('data-lightbox',g);
        $(this).attr('data-title',$(this).attr('title'));
    }); 
}
</script>

...因为当我使用灯箱并将标题标识为 test1 并将图库标识为 test 时,它会生成如下代码:

...because when I use the lightbox and identify the title as test1 and the gallery as test, it generates code like this:

<p><a class="ckelightbox ckelightboxgallerytest" href="myimage.jpg" title="test1">myimage.jpg</a></p>

我认为上面代码的想法是抓取ckelightboxgallerytest并将test"拆分出来,以便将其转换为data-lightbox =test".

I think the idea of the above code is to grab ckelightboxgallerytest and split out "test" so it can turn it into data-lightbox="test."

这篇关于ckeditor 和灯箱不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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