2amigos / yii2-tinymce-widget

TinyMCE WYSIWYG widget for Yii2
http://yiiwheels.com
Other
100 stars 48 forks source link

Add callback? #18

Closed noc2spam closed 8 years ago

noc2spam commented 8 years ago

How do I add callbacks? I am trying this:

<?php
    $func = "function(editor) {editor.addButton('languages', {text : 'Language', type : 'menubutton', icon : false});}";
    echo $form->field($model, 'content')->widget(TinyMce::className(), [
    'clientOptions' => [
    'plugins' => [
    "advlist autolink lists link charmap print preview anchor",
    "searchreplace visualblocks code fullscreen",
    "insertdatetime media table contextmenu paste"
    ],
    'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | languages",
    'setup' => $func

],
    'options' => ['rows' => 12],
    ]);
    ?>

Output is
tinymce.init({ "plugins": ["advlist autolink lists link charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste"], "toolbar": "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | languages", "setup": "function(editor) {editor.addButton('languages', {text : 'Language', type : 'menubutton', icon : false});}", "selector": "#pages-content" }); Which should have been: tinymce.init({ "plugins": ["advlist autolink lists link charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste"], "toolbar": "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | languages", "setup": function(editor) {editor.addButton('languages', {text : 'Language', type : 'menubutton', icon : false});}, "selector": "#pages-content" });

shantinath commented 8 years ago

I am getting an error TypeError: callback is undefined

noc2spam commented 8 years ago

Okay, I needed JsExpression. closing..