Why is my spinner not shown in Turbolinks?

Joe Eifert

I thought of creating a spinner which is displayed while the page is being loaded with Turbolinks. Here is my Coffeescript:

startSpinner = ->
  console.log "started fetching"
  $('html').append('<div id="spinner" class="whirly"></div>')
stopSpinner = ->
  $('#spinner').remove()
  console.log "stopped fetching"


$(document).on("page:fetch", startSpinner());
$(document).on("page:receive", stopSpinner());

The spinner seems to show correctly if I set a breakpoint into stopSpinner (before it removes the spinner), but it is never visible otherwise. What am I missing? Are page:fetch and page:receive the wrong calls?

FYI I took the spinner from http://css-spinners.com/#/spinner/whirly/.

mu is too short

startSpinner() is a function call, not a function reference. jQuery's on wants a function reference as its second argument so you should be saying:

$(document).on("page:fetch",   startSpinner)
$(document).on("page:receive", stopSpinner)

to bind the functions to those events. Your code:

$(document).on("page:fetch", startSpinner());
$(document).on("page:receive", stopSpinner());

is trying to bind the startSpinner and stopSpinner return values to those events and that does nothing useful.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why is the 'prompt' of the android spinner not shown?

From Dev

Rails, Turbolinks and spinner

From Dev

Rails, Turbolinks and spinner

From Dev

why is my spinner not aligned below my image?

From Dev

why is my spinner not aligned below my image?

From Dev

why my picture in gallery isn't shown?

From Dev

Why are horizontal scroll bars shown on my website?

From Dev

Why are these fancy characters not shown in my prompt?

From Dev

Why my viewcontrollers are not being shown on scrollview controller?

From Dev

Mat spinner is not shown

From Dev

Why does my spinner not displaying selected item

From Dev

Why is my custom spinner disabled/unresponsive?

From Dev

Why does my layout file not link up to my spinner?

From Dev

Why pointers are shown instead of string in my inorder traversal of BST?

From Dev

Why my tooltip is not shown if I can see it in the source?

From Dev

why argument of type 'NoneType' is not iterable is shown in my program

From Dev

Why pointers are shown instead of string in my inorder traversal of BST?

From Dev

Why can't my Table View Cell be shown?

From Dev

Why my custom template for a static front page is not shown?

From Dev

Why my files from an NTFS partition are not shown in Gnome Activities search?

From Dev

Why my text Does not appear with the image view in spinner?

From Dev

android spinner drop down items not shown

From Dev

UINavigationItem is not shown in my ViewController

From Dev

My images are not shown in php

From Dev

My item is not shown in the TableView

From Dev

Why is not the :after image shown

From Java

Why are usernames and images not shown?

From Dev

Why both the forms are shown

From Dev

Why are "<" , ">" , " and ' shown in this XML example?

Related Related

  1. 1

    Why is the 'prompt' of the android spinner not shown?

  2. 2

    Rails, Turbolinks and spinner

  3. 3

    Rails, Turbolinks and spinner

  4. 4

    why is my spinner not aligned below my image?

  5. 5

    why is my spinner not aligned below my image?

  6. 6

    why my picture in gallery isn't shown?

  7. 7

    Why are horizontal scroll bars shown on my website?

  8. 8

    Why are these fancy characters not shown in my prompt?

  9. 9

    Why my viewcontrollers are not being shown on scrollview controller?

  10. 10

    Mat spinner is not shown

  11. 11

    Why does my spinner not displaying selected item

  12. 12

    Why is my custom spinner disabled/unresponsive?

  13. 13

    Why does my layout file not link up to my spinner?

  14. 14

    Why pointers are shown instead of string in my inorder traversal of BST?

  15. 15

    Why my tooltip is not shown if I can see it in the source?

  16. 16

    why argument of type 'NoneType' is not iterable is shown in my program

  17. 17

    Why pointers are shown instead of string in my inorder traversal of BST?

  18. 18

    Why can't my Table View Cell be shown?

  19. 19

    Why my custom template for a static front page is not shown?

  20. 20

    Why my files from an NTFS partition are not shown in Gnome Activities search?

  21. 21

    Why my text Does not appear with the image view in spinner?

  22. 22

    android spinner drop down items not shown

  23. 23

    UINavigationItem is not shown in my ViewController

  24. 24

    My images are not shown in php

  25. 25

    My item is not shown in the TableView

  26. 26

    Why is not the :after image shown

  27. 27

    Why are usernames and images not shown?

  28. 28

    Why both the forms are shown

  29. 29

    Why are "<" , ">" , " and ' shown in this XML example?

HotTag

Archive