tinymce 4 loading but showing tinymce.get is undefined - javascript

I'm working in a form update section using Tinymce and jquery and using ejs for load form including textarea and i call tinymce (tinymce init) using JavaScript function right after the ejs loaded.
The editor is working fine, but when i use
tinymce.get("content-text").setContent( $(".grid:first").html() );
for set content to editor its showing error.
if i load the textarea form and load tinymce again it will work ;) I don't what is happening here.

From your comments, what I suggest is that you instantiate tinymce outside your $(document).ready(), and before your html form.

Related

Tag Editor- $(...).jsonTagEditor is not a function

I just tried to implement the json tag editor to create a tag editor.
I want to implement it in a bigger laravel project. Therefore I included jQuery, as well as the js and css file from the json tag editor. It's all loading fine, which I figured out under the network tab.
Now I have:
an input element:
<input id="keywords" class="form-control" name="keywords"
autofocus></div>
and on top of the page I have:
$().ready(function(){
$('#keywords').jsonTagEditor();
});
But i get an error saying
Uncaught TypeError: $(...).jsonTagEditor is not a function...
As I said, the files are loaded as I can see in the network tab...
Any ideas what the problem could be?
Again to make everything clear, I'm using laravel, so the files are all included in the master-layout file and I'm trying to use it in a document that extends this master template. But shouldn't change anything as I'm already using some other plugins that work fine that way.
Any ideas?
After some discussion in chat, the problem turns out to be the suspected re-import and re-initialization of jQuery. The Laravel framework has it's own import of jQuery that happens via require(), and that was the happening after the plugin in question was imported.
Moving the plugin import to the end of the <body> worked around that, but in addition the plugin (as of this writing) has a bug and must be initialized with an empty object passed in (or probably any other value):
$("#keywords").jsonTagEditor({});
You are missing document and just to be certain that the element is accessible, place your script before the ending '</body>' tag so that it loads your page content first.
$(document).ready(function(){
$('#keywords').jsonTagEditor();
});
You forgot to write document
Instead of this
$().ready(function(){});
Use this
$(document).ready( () => {});
The => means, that you use newest standarts of JS
Or you can just use this alternative jQuery tagEditor

a.nativeSelection is null TinyMCE Editor

I have a tinyMCE editor embedded in my page. At times it gets loaded find. Other times it throws "a.nativeSelection is null".
What could be wrong?
I had used multiple tinyMCE editors in same page with same id for the textarea controls over which tinyMCE is applied. This leads to problems of editor not loading perfectly. I have now modified my code to clear the existing editor off the textarea and load the new one. This solved it.

Open CKEDITOR dialog without CKEDITOR

I was triying to open a CKEDITOR dialog without a CKEDITOR editor. I have included the CKEDITOR javascript file and included
var dialogObj = new CKEDITOR.dialog( editor, 'smiley' );
But obviusly editor is not defined and do not know how to instance it without a CKEDITOR input. I'm using CKEDITOR 3.6.4
¿Any idea?
1 way -> in this case you should add document.ptototype.dialog and customize all dialog plugin according to the need.
2 way-> we can add ckeditor in the page and hide that using css then we can use this

tiny mce strips content while posting

I'm using tiny mce in my project which was built using Kohana 3.0.7. If I try to add content to the editor and submit the form, the content is saved properly. But, if there is a validation error and the same page with the validation errors is displayed, there is some issue. After correcting the validation error and adding more content to the mce editor, when I try to post, only the content which was posted at the first attempt is posted. The content which I add after is lost.
I have confirmed this with a plain text-area and sure the editor is causing this. How can I fix this ?
Looks like your textarea content does not get updated after an error.
You may do this manually by calling tinymce.triggerSave(); in your javascript console (firebug or similar tool). triggerSave() orders all tinymce instances to write their content back to the html elment they had been created for.
Update: A javascript console is available using firebug or some other developertools (browser addons). What you need to have it functional all of the time is to use the setup init parameter and a handler: XXXX stands for the handler you will need (an event fired when you post)
setup: function(ed){
ed.onXXXX.add(function(ed, evt){
//console.log('paste');
tinymce.triggerSave();
});
},

jquery load - not able to run the javascripts

I am using jquery ui dialog. In that dialog box, a php file(ex:test.php) is getting loaded using ajax call. Inside the test.php file, it contains some javascript code.
The problem is, after loading the test.php file in to jquery ui dialog, the javascript code inside the test.php file are not getting loaded. Any idea to solve this.
Thanks in advance.
If it is pure inline JavaScript, it should be executed. Does it implement $(document).ready()? In that case the JavaScript will not be executed because the event will never fire. Also be sure your JavaScript code comes after all HTML to allow your script to find the HTML elements.

Categories