N
N
Nazar Jeveling2014-07-13 16:03:08
JavaScript
Nazar Jeveling, 2014-07-13 16:03:08

Why doesn't jQuery work in a Rails web application?

I decided to include jQuery in my Rails web application. First, I added the following line to the Gemfile: gem 'jquery-ui-rails ', because the gem 'jquery-rails' was already there. After that, I installed the gem with the bundle install command . After we add a line with our new library to the app/assets/javascripts/application.js file: //= require jquery.ui.effect-blind
Next, we move on to the most important thing, here is the code that should be executed completely, but does it partially.

$('#current_item').css({'background-color':'#88ff88'}).animate({'background-color':'#114411'}, 1000);


What is executed: each new added product is highlighted with color #88ff88
What is not executed: .animate({'background-color':'#114411'}, 1000)
Although according to the code, the background color of the product should return to the standard one, but this does not happen, I tried to change the commands, only the first part of the line still works.

I also added a line to the beginning of this file to animate the appearance of a new product in the basket.
$('#cart').show('blind', 1000);
What could it be ??

UPD.
// 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
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= ruquire jquery.ui.effect-blind
//= require jquery_ujs
//= require turbolinks
//= require_tree .

Here's what's in application.js.erb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iamnothing, 2014-07-13
@xo8bit

In the latest version of the jquery-ui-rails gem, the file naming scheme has changed. Example:
link to Github , you can read about it there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question