rails_kindeditor icon indicating copy to clipboard operation
rails_kindeditor copied to clipboard

怎么在 kindeditor_tag 里面传入 afterUpload 参数?

Open huanzhiyazi opened this issue 7 years ago • 2 comments

<%= kindeditor_tag “content”, :afterUpload => ... %> 现在我有一个 javascript 的上传回调函数,请问怎么传入这个 afterUpload 参数里面呢?

huanzhiyazi avatar Apr 18 '18 09:04 huanzhiyazi

def kindeditor_tag(name, content = nil, options = {})
      id = sanitize_to_id(name)
      input_html = { :id => id }.merge(options.delete(:input_html) || {})
      input_html[:class] = "#{input_html[:class]} rails_kindeditor"
      output = ActiveSupport::SafeBuffer.new
      output << text_area_tag(name, content, input_html)
      output << javascript_tag(js_replace(id, options))
end

这个是源代码,应该直接按你的方法传入,不行你可以通过chrome查看生成后的代码来调试。

Macrow avatar Apr 18 '18 14:04 Macrow

@Macrow 您说的直接传入我一开始就试过了哈,直接传入函数名到 options 里面页面会报错,源码里面看了貌似是没对这个字段作支持,后来我放弃了 erb 模板方式,改用 K.create('#textarea_id_name', {afterUpload: function(url){}}) 方式来实现的,谢谢~

huanzhiyazi avatar May 17 '18 10:05 huanzhiyazi