1

我正在尝试为小 mce 创建动态生成的图标列表。我已经编写了所有相关的 php 函数,我通过以下代码调用该函数。

$.post(url_file, { 
       content_name: $class_name, 
       page_url: filePath,
       app_code: app_code
   },
   function(data){
       var buttonlist = data;
   });

我需要传递以上 3 个参数才能获得这些图标。现在我有buttonlist。我试过document.write(buttonlist)了,但它给了我missing : after property id错误。我正在尝试在其中打印此内容;

tinyMCE.init({
        mode : "exact",
        elements : "elm1", 
        theme : "advanced",
        plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,
                   style,layer,table,save,advhr,advimage,advlink,
                   emotions,iespell,inlinepopups,insertdatetime,preview,
                   media,searchreplace,print,contextmenu,paste,
                   directionality,fullscreen,noneditable,visualchars,nonbreaking,
                   xhtmlxtras,template",
    --> document.write(buttonlist);
        theme_advanced_toolbar_location : "top",

你知道我如何在tinymce代码中打印这个值吗?非常感谢帮助。

4

2 回答 2

1

您需要动态添加按钮吗?

尝试这个:

要获取它,请为每个按钮行使用 json:

$.post(url_file, { 
   content_name: $class_name, 
   page_url: filePath,
   app_code: app_code
},
function(data){
   var buttons = $.parseJSON(data)
   var buttonlist1 = buttons.line1;
   var buttonlist2 = buttons.line2;
   var buttonlist3 = buttons.line3;
});

然后进行 MCE 初始化:

tinyMCE.init({
    mode : "exact",
    elements : "elm1", 
    theme : "advanced",
    plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,
               style,layer,table,save,advhr,advimage,advlink,
               emotions,iespell,inlinepopups,insertdatetime,preview,
               media,searchreplace,print,contextmenu,paste,
               directionality,fullscreen,noneditable,visualchars,nonbreaking,
               xhtmlxtras,template",
--> theme_advanced_buttons1 : buttonlist1,
--> theme_advanced_buttons2 : buttonlist2,
--> theme_advanced_buttons3 : buttonlist3,
    theme_advanced_toolbar_location : "top",
于 2012-05-31T11:44:58.503 回答
0

当使用 php 创建页面时,php 代码会在页面交付给客户端之前首先执行。因此,您可以执行以下操作:

<?php
    $my_generated_buttonlist = '"bold, italic, underline"';
?>

tinyMCE.init({

    mode : "exact",

    elements : "elm1", 

    theme : "advanced",

    plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

    theme_advanced_buttons1: '<?php echo $my_generated_buttonlist; ?>',

    theme_advanced_toolbar_location : "top",
    ...
于 2012-05-31T09:09:25.447 回答