我们使用gem'bootstrap-wysihtml5-rails','0.3.1.13'。我想在焦点丢失时从textarea保存已更改的内容。Rails&wysihtml5 - 更改后保存
我试图jQuery的直接在视图中使用,通过脚本标签包围:
$("textarea").live("blur", function(){ alert("Focus lost"); });
如果我使用“模糊”(或事件的内容)的警报在页面加载多次触发,而不是当失去焦点,当我使用“改变”时,什么都没有发生。
在另一个尝试我试图钩到wysihtml5的事件与相同的行为:
function integrate_wysihtml5() {
var editor = $('.wysihtml5').each(function(i, elem) {
$(elem).wysihtml5({
"font-styles": false, //Font styling, e.g. h1, h2, etc. Default true
"emphasis": true, //Italics, bold, etc. Default true
"lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
"html": false, //Button which allows you to edit the generated HTML. Default false
"link": false, //Button to insert a link. Default true
"image": false, //Button to insert an image. Default true,
"color": false //Button to change color of font
});
});
function onChange() { alert("The content of the editor has changed"); };
editor.on("change", onChange);
}