I'm trying to acces into an bootstrap-wysihtml5 editor object. I'm doing this by this way:
$(document).ready(function () {
$('.someLink').live('click', function () {
var wysihtml5Editor = $('#textarea').wysihtml5().editor;
console.log('wysihtml5Editor: '+wysihtml5Editor);
wysihtml5Editor.composer.commands.exec("bold");
});
});
Chrome console returns:
> wysihtml5Editor: undefined
> Uncaught TypeError: Cannot read property 'composer' of undefined
So, the point is.
Which is the way to acces into an wysihtml5 object?
The point of everything is insert some html code into my textarea.
Try this:
$(document).ready(function () {
$('.someLink').live('click', function () {
$('#textarea').wysihtml5();
var wysihtml5Editor = $("#textarea").data("wysihtml5").editor;
console.log('wysihtml5Editor: '+wysihtml5Editor);
// The following is important since wysihtml5 is initialized asynchronously
wysihtml5Editor.observe("load", function() {
wysihtml5Editor.composer.commands.exec("bold");
});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With