初始化后,向Froala Editor v2添加选项

时间:2015-09-02 02:50:41

标签: javascript options froala

Froala v2删除了"选项" v2中的方法。编辑器初始化后是否可以更改选项?像这样:

set.seed(1)
z <- setNames(
  data.frame(
    replicate(5000, sample(1:20,10000,replace=TRUE), simplify=FALSE)),
   paste0("a",1:5000))
v1 <- sample(colnames(z), 2500)


system.time(z[v1] <- replace(z, z < 6 | z > 12, NA)[v1])
#   user  system elapsed 
#   6.17    0.00    6.16 

system.time(z[v1] <- lapply(z[v1], function(x) replace(x, x < 6 | x > 12, NA)))
#   user  system elapsed 
#   1.14    0.00    1.13

system.time(is.na(z[v1]) <-  z[v1] < 6 | z[v1] >12)
#   user  system elapsed 
#   2.53    0.00    2.53 

system.time(z[v1][z[v1] < 6 | z[v1] > 12] <- NA)
#   user  system elapsed 
#   2.55    0.00    2.54 

library(data.table)
setDT(z)
system.time(
for(j in v1){
   set(z, i = which(z[[j]] < 6 | z[[j]] > 12), j = j, value = NA_integer_)
}
)
#   user  system elapsed 
#   1.03    0.00    1.03

2 个答案:

答案 0 :(得分:3)

如何获取Froala编辑器实例:

var editor = $('.textarea-selector').data('froala.editor')

然后你可以重新配置你的Froala:

var newOpts = {saveParams: {title: $title.val()}}
$.extend(editor.opts, newOpts)

https://github.com/froala/wysiwyg-editor/issues/53

答案 1 :(得分:0)

尝试如下所示。

var $title = $('#title');

$edit.on('froalaEditor.save.before', function (e, editor) {
    $.extend(editor.opts.saveParams, {
        title : $title.val()
    });
});