backbone-shortcuts

    0.0.2 • Public • Published

    Backbone.Shortcuts

    Backbone.js + Keymaster.js = Backbone.Shortcuts.

    Downloads

    Dependencies

    Usage

    HTML

    Place snippets inside of the <head>...</head> tags.

    <script src="underscore.min.js"></script>
    <script src="backbone.min.js"></script>
    <script src="keymaster.min.js"></script>
    <script src="backbone.shortcuts.min.js"></script>

    JavaScript

    var ShortcutKeys = Backbone.Shortcuts.extend({
      shortcuts: {
        "ctrl+r" : "reloadPage"
      },
      reloadPage: function() {
        alert("Reloaded!!");
      }
    });
     
    var shortcuts = new ShortcutKeys;

    CoffeeScript

    class ShortcutKeys extends Backbone.Shortcuts
      shortcuts:
        "ctrl+r" : "reloadPage"
      reloadPage: -> alert "Reload!!!"
     
    shortcuts = new ShortcutKeys

    Finally, you can press Ctrl + r to execute reloadPage() function to see the alert message.

    Use Backbone.Shortcuts as Delegation for your Backbone.View

    You have to _.extend the this as desination and new Backbone.Shortcuts as source then finally call the delegate function this.delegateShortcuts();.

    See My jsFiddle Example

    Author

    Bryan Goines, @bryangoines

    License

    Backbone.Shortcuts is licensed under MIT license.

    Keywords

    none

    Install

    npm i backbone-shortcuts

    DownloadsWeekly Downloads

    4

    Version

    0.0.2

    License

    unknown

    Last publish

    Collaborators

    • widen-npm
    • feltnerm
    • mskelton
    • rnicholus