【问题标题】:TinyMCE in a popup with jquery load带有 jquery 加载的弹出窗口中的 TinyMCE
【发布时间】:2012-04-15 19:01:36
【问题描述】:

我正在尝试为我的 textarea 使用最新的 tiny mce -TinyMCE 3.5b3 jQuery package 的 jquery 版本。我创建了一个弹出窗口来加载表单,这就是问题所在 - 在 first 加载之后,如果您再次单击相同的加载弹出按钮,ajax load 将会中断。

这里是link,看看我的意思。

但是,我用另一个 ajax load 没有弹出窗口进行了测试,然后 jquery ajax 就可以正常工作了。

jquery,

$('.button-popup').click(function(){

    var object = $(this);

    // Remove any previous popup first.
    $(".popup").remove();

    // Now prepend a fresh popup.
    $(document.body).prepend("<div id='popup-edit' class='popup'></div>");

    // Load the content into the popup.
    $('#popup-edit').load('full.html', {}, function(){

        $('#binder-form').prepend("<div class='close'><a href='#' class='button-close'> x close </a></div>");   

        $('#binder-form').css({
            padding:"20px", 
            backgroundColor:"#ffffff"
        });

        $('textarea.tinymce').get_tinymce();
        $('form *[title]').inputHints();
        $('.button-submit').submit_form();

        $('.close').click(function(){
            $('.popup').fadeOut('fast',function(){
                //$(this).remove();
            });
            return false;
        });

    });

    return false;
});

$('.button').click(function(){

    $('.content').load('full.html', function() {
        $('textarea.tinymce').get_tinymce();
        $('form *[title]').inputHints();
        $('.button-submit').submit_form();

    });

    return false;
});

$('textarea.tinymce').get_tinymce();的插件在jsfiddle

【问题讨论】:

    标签: jquery tinymce


    【解决方案1】:

    问题是关闭模式后#binder-form 仍然在页面上。您应该在模式关闭时删除 #binder-form 元素。

    只需取消注释在关闭点击事件中被注释掉的那一行:

        $('.close').click(function(){
            $('.popup').fadeOut('fast',function(){
                $(this).remove(); // this will remove the popup element
            });
            return false;
        });
    

    我倾向于避免在使用 ajax 的页面中依赖元素 id 属性。拥有两个具有相同 id 的元素会导致各种难以捕捉的错误。坚持在 jQuery 中为此使用类选择器。

    [编辑] 嗯,不,你是对的,你在下次点击时删除了.popup,一个异常会导致它破坏点击处理程序并点击链接到full.html

    我会说小 mce 出于某种原因抛出错误,尝试将其包装在 try catch 块中以查看确切原因。

    【讨论】:

    • 感谢您的回答,try to wrap it in a try catch block to see why exactly - 我该怎么做?
    • 这可能是他们的问题,代码中可能存在拼写错误。我已经提交了bug report,我们会看看情况如何。
    • 感谢您提交错误报告。我认为这可能是他们的错误,因为它没有任何意义。
    • 我也遇到了这个错误,但我不知道如何向他们提交票证 - stackoverflow.com/questions/10166099/…
    猜你喜欢
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多