我成功地将我的应用程序部署到 Site5 - 当我开始使用它时,我意识到并非所有的 jQuery 都在工作。具体来说,任何涉及从 Ruby Forms 获取信息的事情。我收到以下错误:
Uncaught TypeError: Object [object Object] has no method 'live'
Uncaught TypeError: Object [object Object] has no method 'live'
(anonymous function)
(anonymous function)
ut.extend.globalEval
ut.fn.extend.domManip
ut.fn.extend.replaceWith
(anonymous function)
ut.event.dispatch
y.handle
该脚本如下所示,并在本地、heroku 和 hostmonster 上工作,所以我很困惑为什么它现在不起作用。在文档中:
<%= form_for :team_design, :url => {:controller => "team_designs", :action => 'create'} do |f| %>
<%= f.label :style %> <%= f.select :style, [["Mens", "Mens"], ["Womens", "Womens"]], :include_blank=>'Select Style' %>
...
$(document).ready(function() {
$('#target_div select#team_design_style').live('change', function () {
var suitStyle = $(this).val();
switch (suitStyle) {
//all the different case possibilities
});
});
在 Application.js 中:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_tree .
在我的布局文件中
<head>
<title>scrubbed</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
在我的 Gemfile 中,在资产下
group :assets do
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
gem 'johnson'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'jquery-rails'
gem 'uglifier', '>= 1.0.3'
end
在 Google Chrome 中的来源下:
/*!
* jQuery JavaScript Library v1.9.1
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2013-2-4
*/
* Sizzle CSS Selector Engine
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license
* http://sizzlejs.com/
*/
* http://jqueryui.com
* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
* Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */