文本编辑器wysihtml5未加载并在控制台中显示错误

时间:2013-07-19 13:17:48

标签: ruby-on-rails

我正在使用WYSIHTML5文本编辑器在rails应用程序中无效。我尝试在描述字段中包含文本编辑器。但它在控制台中显示错误,

Uncaught TypeError: Cannot set property 'mo-MD' of undefined ar-AR.js:6
Uncaught TypeError: Cannot set property 'bg-BG' of undefined bg-BG.js:6
Uncaught TypeError: Cannot set property 'ca-CT' of undefined ca-CT.js:6
Uncaught TypeError: Cannot set property 'cs-CZ' of undefined cs-CZ.js:6
Uncaught TypeError: Cannot set property 'da-DK' of undefined da-DK.js:6
Uncaught TypeError: Cannot set property 'de-DE' of undefined de-DE.js:6
Uncaught TypeError: Cannot set property 'el-GR' of undefined el-GR.js:6
Uncaught TypeError: Cannot set property 'es-AR' of undefined es-AR.js:7
Uncaught TypeError: Cannot set property 'es-ES' of undefined es-ES.js:6
Uncaught TypeError: Cannot set property 'fr-FR' of undefined fr-FR.js:6
Uncaught TypeError: Cannot set property 'nl-NL' of undefined fr-NL.js:6
Uncaught TypeError: Cannot set property 'hr-HR' of undefined hr-HR.js:6
Uncaught TypeError: Cannot set property 'it-IT' of undefined it-IT.js:6
Uncaught TypeError: Cannot set property 'ja-JP' of undefined ja-JP.js:6
Uncaught TypeError: Cannot set property 'ko-KR' of undefined ko-KR.js:6
Uncaught TypeError: Cannot set property 'lt-LT' of undefined lt-LT.js:6
Uncaught TypeError: Cannot set property 'mo-MD' of undefined mo-MD.js:6
Uncaught TypeError: Cannot set property 'nb-NB' of undefined nb-NB.js:6
Uncaught TypeError: Cannot set property 'nl-NL' of undefined nl-NL.js:6
Uncaught TypeError: Cannot set property 'pl-PL' of undefined pl-PL.js:6
Uncaught TypeError: Cannot set property 'pt-BR' of undefined pt-BR.js:6
Uncaught TypeError: Cannot set property 'ru-RU' of undefined ru-RU.js:6
Uncaught TypeError: Cannot set property 'sk-SK' of undefined sk-SK.js:6
Uncaught TypeError: Cannot set property 'sv-SE' of undefined sv-SE.js:6
Uncaught TypeError: Cannot set property 'tr-TR' of undefined tr-TR.js:6
Uncaught TypeError: Cannot set property 'ua-UA' of undefined ua-UA.js:6
Uncaught TypeError: Cannot set property 'zh-CN' of undefined zh-CN.js:6
Uncaught TypeError: Cannot set property 'zh-TW' of undefined zh-TW.js:6
Uncaught TypeError: Cannot read property 'editor' of undefined announcements.js:1

Js文件

$('.wysihtml5').wysihtml5();

的application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery.ui.datepicker
//= require twitter/bootstrap
//= require bootstrap-datepicker
//= require bootstrap-datetimepicker
//= require bootstrap-wysihtml5
//= require bootstrap-wysihtml5/locales
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap
//= require jquery.timepicker.js
//= require rails.validations
//= require rails.validations.custom
//= require rails.validations.simple_form
//= require_tree .

application.css

*= require_self
 *= require datepicker
 *= require datetimepicker
 *= require dataTables/jquery.dataTables.bootstrap
 *= require DT_bootstrap
 *= require bootstrap-wysihtml5
 *= require jquery.ui.datepicker
 *= require jquery.timepicker.css
 *= require_tree .

的Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'mysql2'
gem 'jquery-rails'
gem 'rspec-rails'
gem 'simple_form'
gem 'country_select'
gem 'bcrypt-ruby', '~> 3.0.0'
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
gem 'jquery-fileupload-rails'
gem 'kendoui-rails'
gem 'wicked'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'bootstrap-wysihtml5-rails', :require => 'bootstrap-wysihtml5-rails',
                              :git => 'git://github.com/Nerian/bootstrap-wysihtml5-rails.git'
gem 'client_side_validations'
gem 'client_side_validations-simple_form'
gem 'validates_timeliness', '~> 3.0'
group :assets do
  gem 'sass-rails',   '~> 3.2.5'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'less-rails'
  gem "therubyracer"
  gem 'jquery-ui-rails'
  gem 'jquery-timepicker-rails'
end

_form.html.erb文件

<%= simple_form_for @announcement, :html => { :class => 'form-horizontal' } do |f| %>
  <%= f.input :name %><br/>
  <%= f.input :description, as: 'text', :input_html =>{:rows =>8, :cols => 15, :class => 'wysihtml5' } %>
  <div class="form-actions">
    <%= f.button :submit, :class => 'btn-primary' %>
    <%= link_to t('.cancel', :default => t("helpers.links.cancel")),
                announcements_path, :class => 'btn' %>
  </div>
<% end %>

我整天都在尝试。虽然我收到了错误。请帮助我......

1 个答案:

答案 0 :(得分:1)

如果你的资产文件夹中有bootstrap-wysihtml5.js和bootstrap-wysihtml5.min.js这些文件。只是你可以删除这些文件。我想,它会起作用。