0

我正在自定义 Refinery CMS 实例并创建自定义前端页面。我尝试按照 Wymeditor 的 README 进行操作,但似乎 RefineryCMS 中嵌入的 Wymeditor 已被修改,这不起作用。

https://github.com/wymeditor/wymeditor

我尝试使用编辑器查看 Refinery 管理页面的源代码,然后将 Javascript 和 CSS 源代码标签复制到我的前端自定义页面中,并将类添加到文本区域,并调用该wymeditor()函数,但它给出了Javascript 错误。

HTML source...
<link href="/assets/wymeditor/skins/refinery/skin.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<script src="/assets/wymeditor/setup.js?body=1" type="text/javascript"></script>
<script src="/assets/wymeditor/functions.js?body=1" type="text/javascript"></script>
...

产生控制台错误

Uncaught TypeError: Cannot read property 'msie' of undefined boot_wym.js?body=1:117
4

2 回答 2

0

Try a version of jquery older than 1.9. The .browser method has been removed in 1.9

You can also try this monkey patch of js

jQuery.browser = {};
  (function () {
    jQuery.browser.msie = false;
    jQuery.browser.version = 0;
    if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
      jQuery.browser.msie = true;
      jQuery.browser.version = RegExp.$1;
  }
})();
于 2014-03-23T23:25:13.220 回答
0

I added this immediately after the textarea. I wasn't able to get it to work with the JQuery that came with Refinery (even with jquery-migrate), and I wasn't able to get it to work with the Wymeditor that came with Refinery either. I don't believe this is the ideal solution, but it's all I could come up with for now. I'm sure it will break something else, as the console is giving errors like 'Object has no method carousel' now. I don't want to put an old JQuery in the application.js or application.haml layout, so hopefully this will localize breakage. Open to more ideas...

  = f.text_area  :body, rows: 15, cols: 100, class: 'wymeditor'
<script type="text/javascript" src="/assets/jquery/jquery.js"></script>
<script type="text/javascript" src="/assets/wymeditor/jquery.wymeditor.js"></script> 
:javascript
  jQuery(function() {
    $('.wymeditor').wymeditor();
    console.log("initialized .wymeditor: "+$('.wymeditor'));
  });
于 2014-03-24T01:42:35.527 回答