我正在尝试为小型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代码中打印这个值吗? 非常感谢。
答案 0 :(得分: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",
答案 1 :(得分: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",
...