<tfoot id='mKlGh'></tfoot>

    <i id='mKlGh'><tr id='mKlGh'><dt id='mKlGh'><q id='mKlGh'><span id='mKlGh'><b id='mKlGh'><form id='mKlGh'><ins id='mKlGh'></ins><ul id='mKlGh'></ul><sub id='mKlGh'></sub></form><legend id='mKlGh'></legend><bdo id='mKlGh'><pre id='mKlGh'><center id='mKlGh'></center></pre></bdo></b><th id='mKlGh'></th></span></q></dt></tr></i><div id='mKlGh'><tfoot id='mKlGh'></tfoot><dl id='mKlGh'><fieldset id='mKlGh'></fieldset></dl></div>
  1. <small id='mKlGh'></small><noframes id='mKlGh'>

    • <bdo id='mKlGh'></bdo><ul id='mKlGh'></ul>
      <legend id='mKlGh'><style id='mKlGh'><dir id='mKlGh'><q id='mKlGh'></q></dir></style></legend>
    1. JQuery 事件不在生产中的 heroku 上工作,而是在开发中工作

      时间:2024-04-19

      <small id='ndLdO'></small><noframes id='ndLdO'>

          <tbody id='ndLdO'></tbody>
        <legend id='ndLdO'><style id='ndLdO'><dir id='ndLdO'><q id='ndLdO'></q></dir></style></legend>
          <i id='ndLdO'><tr id='ndLdO'><dt id='ndLdO'><q id='ndLdO'><span id='ndLdO'><b id='ndLdO'><form id='ndLdO'><ins id='ndLdO'></ins><ul id='ndLdO'></ul><sub id='ndLdO'></sub></form><legend id='ndLdO'></legend><bdo id='ndLdO'><pre id='ndLdO'><center id='ndLdO'></center></pre></bdo></b><th id='ndLdO'></th></span></q></dt></tr></i><div id='ndLdO'><tfoot id='ndLdO'></tfoot><dl id='ndLdO'><fieldset id='ndLdO'></fieldset></dl></div>
              <bdo id='ndLdO'></bdo><ul id='ndLdO'></ul>

              1. <tfoot id='ndLdO'></tfoot>

              2. 本文介绍了JQuery 事件不在生产中的 heroku 上工作,而是在开发中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这似乎是一个常见问题,但我还没有找到适用于我的案例的解决方案.我在 bikes.js.coffee 中有一些 JQuery 可以在本地开发中正常工作.当我推送到 Heroku 时,bikes.js.coffee 中的脚本不会运行.浏览器的 javascript 控制台中没有错误.我正在使用 Rails 4.0.通过阅读,我认为资产的编译方式存在一些错误,但我无法超越.所有图像在生产中都显示良好.

                this seems to be a common problem but I haven't found a solution applicable for my case. I have some JQuery in bikes.js.coffee that works correctly in development locally. When I push to Heroku the script in bikes.js.coffee does not run. There is no error in the browser's javascript console. I am using Rails 4.0. From reading around I believe it is some error in the way the assets are compiled but I am unable to get beyond that. All images show up fine in production.

                bikes.js.coffee:

                bikes.js.coffee:

                ready = ->
                  jQuery ($) ->
                
                  # when the #make field changes
                  $("#bike_make_id").change ->
                
                    # make a POST call and replace the content
                    make = $("select#bike_make_id :selected").val()
                    make = "0"  if make is ""
                    jQuery.get "/bikes/update_model_select/" + make, (data) ->
                      $("#bikeModels").html data
                
                    false
                
                $(document).ready(ready)
                $(document).on('page:load', ready)
                

                应用程序.js

                //= require jquery
                //= require jquery_ujs
                //= require jquery.turbolinks
                //= require bootstrap/bootstrap
                //= require turbolinks
                //= require_tree .
                

                宝石文件

                source 'https://rubygems.org'
                ruby '1.9.3'
                #ruby-gemset=reride_app
                
                gem 'rails', '4.0.0'
                gem 'bcrypt-ruby', '3.0.1'
                gem 'faker', '1.1.2'
                gem 'will_paginate', '3.0.4'
                gem 'bootstrap-will_paginate', '0.0.9'
                gem "mechanize", "~> 2.7.2"
                gem 'pg', '0.15.1'
                gem "simple_form", "~> 3.0.0.rc"
                gem 'jquery-turbolinks'
                gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
                gem 'aws-sdk', '~> 1.5.7'
                
                group :development, :test do
                  gem 'rspec-rails', '2.13.1'
                  # The following optional lines are part of the advanced setup.
                  gem 'guard-rspec', '2.5.0'
                  gem 'spork-rails', github: 'sporkrb/spork-rails'
                  gem 'guard-spork', '1.5.0'
                  gem 'childprocess', '0.3.6'
                  gem 'railroady', '1.1.1'
                end
                
                group :test do
                  gem "shoulda-matchers", github: "thoughtbot/shoulda-matchers" , branch: 'dp-rails-four' #To test model relationships simply
                  gem 'selenium-webdriver', '2.0.0'
                  gem 'capybara', '2.1.0'
                  gem 'factory_girl_rails', '4.2.0'
                  gem 'cucumber-rails', '1.3.0', :require => false
                  gem 'database_cleaner', github: 'bmabey/database_cleaner'
                
                  # Uncomment this line on OS X.
                  gem 'growl', '1.0.3'
                
                  # Uncomment these lines on Linux.
                  # gem 'libnotify', '0.8.0'
                
                  # Uncomment these lines on Windows.
                  # gem 'rb-notifu', '0.0.4'
                  # gem 'win32console', '1.3.2'
                end
                
                gem 'sass-rails', '4.0.0'
                gem 'uglifier', '2.1.1'
                gem 'coffee-rails', '4.0.0'
                gem 'jquery-rails', '2.2.1'
                gem 'turbolinks', '1.1.1'
                gem 'jbuilder', '1.0.2'
                
                group :doc do
                  gem 'sdoc', '0.3.20', require: false
                end
                
                group :production do
                  gem 'rails_12factor', '0.0.2'
                end
                

                开发.rb

                RerideApp::Application.configure do
                  config.cache_classes = false
                  config.eager_load = false
                  config.consider_all_requests_local       = true
                  config.action_controller.perform_caching = false
                  config.action_mailer.raise_delivery_errors = false
                  config.active_support.deprecation = :log
                  config.active_record.migration_error = :page_load
                  config.assets.debug = true
                
                  Paperclip.options[:command_path] = "/usr/local/bin/"
                end
                

                生产.rb

                config.cache_classes = true
                  config.eager_load = true
                  config.consider_all_requests_local       = false
                  config.action_controller.perform_caching = true
                  config.serve_static_assets = true
                  config.assets.js_compressor = :uglifier
                  config.assets.compile = false
                  config.assets.digest = true
                  config.assets.version = '1.0'
                  config.log_level = :info
                  config.i18n.fallbacks = true
                  config.active_support.deprecation = :notify
                  config.log_formatter = ::Logger::Formatter.new
                

                当我运行本地服务器并查看源代码"时,我得到的是:

                When I run my local server and 'view source' here is what I get:

                <script data-turbolinks-track="true" src="/assets/jquery.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/jquery_ujs.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/jquery.turbolinks.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/affix.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/alert.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/button.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/carousel.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/collapse.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/dropdown.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/modal.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/popover.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/scrollspy.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/tab.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/tooltip.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/transition.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bootstrap/bootstrap.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/turbolinks.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/analytics.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bike_shops.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/bikes.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/contacts.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/customers.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/inspections.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/make.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/model.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/quotes.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/resellers.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/static_pages.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/transactions.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/users.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/year.js?body=1"></script>
                <script data-turbolinks-track="true" src="/assets/application.js?body=1"></script>
                

                推荐答案

                我注意到在 javascript 控制台中有一个未捕获的异常Popover 需要 tooltip.js".这两个 js 文件是引导框架的一部分,并且以错误的顺序编译.我删除了

                I notice that in the javascript console there was an uncaught exception "Popover requires tooltip.js". These two js files are part of the bootstrap framework and were being compiled in the wrong order. I removed

                //= 需要引导程序/引导程序

                因为我目前没有使用任何引导 js 库.删除后,bikes.js 中的 javascript 将按预期工作.

                since I am not currently using any of the bootstrap js libraries. After removal, the javascript in bikes.js works as intended.

                这篇关于JQuery 事件不在生产中的 heroku 上工作,而是在开发中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:AngularJS:初始复选框值不在模型中 下一篇:CoffeeScript - 无与伦比的 OUTDENT

                相关文章

              3. <legend id='4etkc'><style id='4etkc'><dir id='4etkc'><q id='4etkc'></q></dir></style></legend>

                  <tfoot id='4etkc'></tfoot>

                  • <bdo id='4etkc'></bdo><ul id='4etkc'></ul>
                1. <i id='4etkc'><tr id='4etkc'><dt id='4etkc'><q id='4etkc'><span id='4etkc'><b id='4etkc'><form id='4etkc'><ins id='4etkc'></ins><ul id='4etkc'></ul><sub id='4etkc'></sub></form><legend id='4etkc'></legend><bdo id='4etkc'><pre id='4etkc'><center id='4etkc'></center></pre></bdo></b><th id='4etkc'></th></span></q></dt></tr></i><div id='4etkc'><tfoot id='4etkc'></tfoot><dl id='4etkc'><fieldset id='4etkc'></fieldset></dl></div>
                  1. <small id='4etkc'></small><noframes id='4etkc'>