Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added Mousetrap reset whenever keybindings get reloaded. #8

Merged
merged 1 commit into from

3 participants

@thierry-rietsch

It is required to reset the Mousetrap.js library as turbolinks does not refresh the page. Therefore some old keybindings might still be present.

To reproduce create the following steps:

1) Create a page which lists all entities of type X (index.html.erb)
2) Create a detail page for an entity of type X (show.html.erb) incl. an edit link (with keybinding 'e').
3) Enable turbolinks
4) Visit the index page, then navigate to one of the entities.
5) Go back to the index page and press 'e'. You get now to the edit view of the previous visited entity.

@thierry-rietsch thierry-rietsch Added Mousetrap reset whenever keybindings get reloaded.
It is required to reset the Mousetrap.js library as turbolinks does not refresh the page. Therefore some old keybindings might still be present.
e422fc3
@coveralls

Coverage Status

Coverage decreased (-1.79%) when pulling e422fc3 on thierry-rietsch:master into fe31fe3 on kugaevsky:master.

@kugaevsky kugaevsky merged commit cd312a6 into kugaevsky:master
@kugaevsky
Owner

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 14, 2013
  1. @thierry-rietsch

    Added Mousetrap reset whenever keybindings get reloaded.

    thierry-rietsch authored
    It is required to reset the Mousetrap.js library as turbolinks does not refresh the page. Therefore some old keybindings might still be present.
This page is out of date. Refresh to see the latest.
View
3  lib/generators/mousetrap/install/templates/keybindings.js.coffee
@@ -5,6 +5,9 @@ $(document).on 'page:change', ->
handleKeyBindings()
handleKeyBindings = ->
+ # As turbolinks does not refresh the page, some old keybindings could be still present. Therefore a reset is required.
+ Mousetrap.reset()
+
# Hotkey binding to links with 'data-keybinding' attribute
# Navigate link when hotkey pressed
$('a[data-keybinding]').each (i, el) ->
Something went wrong with that request. Please try again.