small medium large xlarge

17 Nov 2016, 15:43
Dong.Xu (6 posts)

I added the code

if ($("#cart tr").length == 0) {
  $("#cart").show('blind', 1000);

in create.js.erb, but when I add book to cart, the side bar just show the cart content, but no animation.

18 Nov 2016, 21:03
mbigras (1 post)


I was just running into some problems with this section.

Make sure you remove your unless statement in _cart.html.erb

Also you need to check for a length of 1 like so:

if ($('#cart tr').length == 1) { $('#cart').show('blind', 1000); }
03 Feb 2017, 17:58
zhiguang xu (1 post)

Not working for me.

19 Feb 2017, 15:19
Sam Ruby (634 posts)

Try going into your browser’s javascript console and entering the following:

document.querySelectorAll("#cart tr").length

When there is no cart shown, this should return a 1 as there should be a hidden total line. If it returns a zero, make sure that you have defined a div with an id of cart, and included the table within that div.

22 Mar 2017, 09:38
James West (104 posts)

Same problem here with Rails 5.2 Empty cart browser console shows

document.querySelectorAll(“#cart tr”).length


So that’s all good. JQuiry is working as I get the flash effects when updating cart just no effect when displaying the cart from empty

02 Apr 2017, 07:04
Dong.Xu (6 posts)

The way said in Dima Rogov’s post works for me.


form, div {
   display: inline;

in #side of application.scss

but with something weird.

You must be logged in to comment