Reputation: 1617
i'm trying to create dynamically generated icon list for tiny mce. I have written all related php functions i call the function through following code.
$.post(url_file, {
content_name: $class_name,
page_url: filePath,
app_code: app_code
},
function(data){
var buttonlist = data;
});
i need to pass above 3 parameters in order to get these icons . Now i have buttonlist
. I tried document.write(buttonlist)
but it gives me missing : after property id
error.
i am trying to print this within ;
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",
Do you have an idea how i can print this value inside tinymce code? Help much much appreciated.
Upvotes: 1
Views: 475
Reputation: 15616
you need to add the buttons dynamically right?
try this:
for getting it, use json for each button line:
$.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;
});
and then for MCE initialization:
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",
Upvotes: 1
Reputation: 50832
When creating a page using php the php code gets executed first before the page gets delievered to the client. Therefor you may do something like:
<?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",
...
Upvotes: 0