okbreathe/jquery_plugins — Issue #6: jquery.okShortcut with 2 shortcuts on the same page does not work
Author: mliebelt
Created: 2011-10-17 12:01:53+00:00
State: open

I want to use different shortcuts on the same page and have added the following to my rails application.js file:

```javascript
function _mapShortcuts() {
var elements = document.getElementsByClassName("shortcut");
for (var i = 0; i < elements.length; i++) {
var ele = elements[i];
var shortcut = ele.getAttribute('data-shortcut');
var path = ele.getAttribute('data-path');
$.shortcut.add(shortcut, function(){
window.location = path;
})
}
}
$(function() { _mapShortcuts() });

In the Rails code, I insert code so that the resulting HTML page has the following part:

```html
Edit
Back

When I now visit the page and press CTRL-E (for editing), I'm redirected to the url http://localhost/notices which has the shortcut CTRL-B.

Is it possible to use more than one shortcut on the same page for the same element?