What's wrong with this code? (TineMCE)
-
Hey,
I’m trying to make a button that when it clicked, it wrap some text with shortcodes.
Everything went good and I did this button, but now, I want to go to the next step which is to make the button a menu button, with several options inside it. but for some reason, it doesn’t work.
This is the js. code that does work:(function() { tinymce.create('tinymce.plugins.dropcapButton', { init : function(ed) { ed.addButton('dropcap', { title : 'testMenuButton', icon : 'icon dashicons-wordpress-alt', cmd:"dropcap" }); ed.addCommand("dropcap", function() { var selected_text = ed.selection.getContent(); var return_text = ''; return_text = '[col-num]' + selected_text + '[/col-num]'; ed.execCommand('mceInsertContent', 0, return_text); }); }, }); // Register plugin tinymce.PluginManager.add( 'dropcap', tinymce.plugins.dropcapButton ); })();But when I try this one, simply nothing happens when I press the button inside the main button.
(function() { tinymce.create('tinymce.plugins.dropcapButton', { init : function(ed) { ed.addButton('dropcap', { title : 'testMenuButton', type : 'menubutton', icon : 'icon dashicons-wordpress-alt', menu : [{ text : "1", title : 'DropCap', cmd : "dropcap", icon : 'icon dashicons-wordpress-alt' }] }); ed.addCommand("dropcap", function() { var selected_text = ed.selection.getContent(); var return_text = ''; return_text = '[col-num]' + selected_text + '[/col-num]'; ed.execCommand('mceInsertContent', 0, return_text); }); }, }); // Register plugin tinymce.PluginManager.add( 'dropcap', tinymce.plugins.dropcapButton ); })();Thanks in advance!
The topic ‘What's wrong with this code? (TineMCE)’ is closed to new replies.