Closed breakliu closed 11 years ago
turbolinks的机制就是这样的,页面根本没刷新,这和pjax是一样的,所以kindeditor没加载很正常。
有两个办法可以解决: 1.在需要加载kindeditor的链接加入 'data-no-turbolink' => true ,此时相当在这个页面于关闭turbolinks。
<%= link_to 'Edit', edit_article_path(article), 'data-no-turbolink' => true %>
2.在turbolinks载入完毕后手动加载kindeditor,不过所有参数都要设置,而且需要知道并设定textarea的id。
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content', "width":"100%","height":300,"allowFileManager":true,"uploadJson":"/kindeditor/upload","fileManagerJson":"/kindeditor/filemanager"
simple模式也需要手动设定
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content',
"width":"100%",
"height":300,
"allowFileManager":true,
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager",
"items":["fontname","fontsize","|","forecolor","hilitecolor","bold","italic","underline","removeformat","|","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","|","emoticons","image","link"]
嗯,我好像发现一个新的问题,我觉得是Rails 4.0.0.rc1的assets有问题的,现在production出现 /assets/kindeditor/themes/default/default.css /assets/kindeditor/lang/zh_CN.js?ver=4.1.7%20(2013-04-21) 的404 我检查一下先
你用的什么服务器?如果没用前端服务器,后端服务器静态文件的服务是关了的,请检查一下,可以手动打开。
我用的是Apache + Passenger
http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html
In Rails 4.0, precompiling assets no longer automatically copies non-JS/CSS assets from vendor/assets and lib/assets. Rails application and engine developers should put these assets in app/assets or configure config.assets.precompile.
在development的环境没问题,布置出去production就出问题,蛋疼,还有个是这样 https://github.com/bokmann/font-awesome-rails
你有没有临时的解决方案?
我暂时把文件copy到public/assets/里顶着先
设置
'data-no-turbolink' => true
以后,每次点开一个编辑页面,kindeditor 的显示会有延迟,我这边 development 的状态下是先显示出一个小小的默认编辑框,马上再加载上 kindeditor,这个是因为有 turbolinks 就只能这样了吗?
Kindeditor本身就是这样的,因为加载javascript完成后,再由Kindeditor的js来将文本框“变为”kindeditor,所以看上去会有一个延迟,如果客户端有了缓存以后,这个动作应该会快一点,都是正常的。
打开turbolinks时,rails_kindeditor要刷新一下才显示出来,不知这个问题有什么解决方案,要手写js?