3

我的页面包含 5 个 div,可以通过 Tinymce 内联编辑器进行编辑。通过单击一个按钮(如此动态地),我对 Jquery loding 5 个新的感到满意。但是当然新的不受 Tinymce 的影响,因为 init 已经加载了......请问我怎样才能为新的 div 激活 tinymce?

我的 HTML:

<div id=\"billetdroit\">
            <div id=\"divtitre\"><h1 class=\"editable\">blablabla</h1></div>
        <div class=\"editable\" id=\"tiny_01\">blablabla2</div>
        </div>
<div id=\"billetdroit\">
                <div id=\"divtitre\"><h1 class=\"editable\">blablabla</h1></div>
            <div class=\"editable\" id=\"tiny_02\">blablabla2</div>
            </div>
<div id=\"billetdroit\">
                <div id=\"divtitre\"><h1 class=\"editable\">blablabla</h1></div>
            <div class=\"editable\" id=\"tiny_03\">blablabla2</div>
            </div>

...
...

还有一个按钮:当您单击时,它会动态显示 5 个 div “billetdroit”

我的tinymce初始化:

tinymce.init({
                    selector: "textarea",
                    language: 'fr_FR',
                    image_advtab: true,
                    menubar:false,
                    forced_root_block: false,
                    plugins: ["link","code","media","image","textcolor", "emoticons"],
                    toolbar: "bold italic forecolor backcolor alignleft aligncenter alignright alignjustify link unlink image media emoticons"
                 });
                 tinymce.init({
                    selector: "h1.editable",
                    language: 'fr_FR',
                    inline: true,
                    toolbar: "undo redo",
                    menubar: false
                });

                tinymce.init({
                    selector: "div.editable",
                    language: 'fr_FR',
                    image_advtab: true,
                    menubar:false,
                    inline: true,
                    forced_root_block: false,
                    plugins: ["link","code","media","image","textcolor", "emoticons"],
                    toolbar: "bold italic forecolor backcolor alignleft aligncenter alignright alignjustify link unlink image media emoticons"
                });

有什么解决办法吗?谢谢

编辑:

我试过了:

$(document).ready(function() {

    var track_click = 1; //track user click on "load more" button, righ now it is 0 click

    var total_pages = Globals.total_pages;

//    $('#results').load("loadmore.php", {'page':track_click}, function() {track_click++;}); //initial data to load


    $(".load_more").click(function (e) { //user clicks on button

        $(this).hide(); //hide load more button on click
        $('.animation_image').show(); //show loading image

        if(track_click <= total_pages) //user click number is still less than total pages
        {
            //post page number and load returned data into result element
            $.post('loadmore.php',{'page': track_click}, function(data) {

                $(".load_more").show(); //bring back load more button

                $("#results").append(data); //append data received from server

                //scroll page smoothly to button id
                $("html, body").animate({scrollTop: $("#load_more_button").offset().top}, 500);

                //hide loading image
                $('.animation_image').hide(); //hide loading image once data is received

                track_click++; //user click increment on load button

            }).fail(function(xhr, ajaxOptions, thrownError) { //any errors?
                alert(thrownError); //alert with HTTP error
                $(".load_more").show(); //bring back load more button
                $('.animation_image').hide(); //hide loading image once data is received
            });


            if(track_click >= total_pages-1) //compare user click with page number
            {
                //reached end of the page yet? disable load button
                $(".load_more").attr("disabled", "disabled");
            }
         }
         $.getScript('include/tinymce/tinymce.min.js', function() {
            tinymce.init({
                    selector: "textarea",
                    language: 'fr_FR',
                    image_advtab: true,
                    menubar:false,
                    forced_root_block: false,
                    plugins: ["link","code","media","image","textcolor", "emoticons"],
                    toolbar: "bold italic forecolor backcolor alignleft aligncenter alignright alignjustify link unlink image media emoticons"
                 });
                 tinymce.init({
                    selector: "h1.editable",
                    language: 'fr_FR',
                    inline: true,
                    toolbar: "undo redo",
                    menubar: false
                });

                tinymce.init({
                    selector: "div.editable",
                    language: 'fr_FR',
                    image_advtab: true,
                    menubar:false,
                    inline: true,
                    forced_root_block: false,
                    plugins: ["link","code","media","image","textcolor", "emoticons"],
                    toolbar: "bold italic forecolor backcolor alignleft aligncenter alignright alignjustify link unlink image media emoticons"
                });
            });

        });
});

但是没有成功...

4

1 回答 1

0

有一个简单的方法来初始化 tinymce 编辑器:

tinyMCE.execCommand("mceAddControl", false, 'your_div_id');
于 2013-06-12T07:31:06.473 回答