访问bootstrap-wysihtml5编辑器对象 [英] access the bootstrap-wysihtml5 editor object

查看:142
本文介绍了访问bootstrap-wysihtml5编辑器对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加入bootstrap-wysihtml5编辑器对象.我通过这种方式做到这一点:

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控制台返回:

Chrome console returns:

> wysihtml5Editor: undefined
> Uncaught TypeError: Cannot read property 'composer' of undefined

所以,重点是

哪种方式可以加入wysihtml5对象?

Which is the way to acces into an wysihtml5 object?

一切都是在我的文本区域中插入一些html代码.

The point of everything is insert some html code into my textarea.

推荐答案

尝试一下:

$(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");
     });
   });
});

这篇关于访问bootstrap-wysihtml5编辑器对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆