Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
huanzhiyazi opened this issue Apr 18, 2018 · 2 comments
Open

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

huanzhiyazi opened this issue Apr 18, 2018 · 2 comments

Comments

@huanzhiyazi
Copy link

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

@Macrow
Copy link
Owner

Macrow commented Apr 18, 2018

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查看生成后的代码来调试。

@huanzhiyazi
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants