0

アプリを 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 */
4

2 に答える 2

2

細かいjQueryマニュアルから:

.live( events, handler(eventObject) ) 戻り値: jQuery
バージョン非推奨: 1.7、削除: 1.9
[...]
jQuery 1.7 の時点で、この.live()メソッドは非推奨です。.on()イベント ハンドラーをアタッチするために使用します。古いバージョンの jQuery のユーザーは、 よりも.delegate()優先して使用する必要があります.live()

そのliveため、バージョン 1.7 (2011 年 11 月) で廃止され、1.9 で完全に削除されました。jQuery 1.9.1 を使用しているため、これ以上はありませんlive。一部の場所では機能したが、他の場所では機能しなかったと言うので、jQueryのバージョンを混在させる必要があります.

onの代わりに使用するように jQuery コードを更新します。とのドキュメントは、とをに変換する方法を示しています。livedelegatelivedelegatelivedelegateon

リリース ノートに注意を払い、コードを更新する必要があります。機能が削除されるまで待たずに、非推奨になったらすぐにコードを更新してください。

于 2013-04-11T18:53:43.823 に答える