浏览代码

Update bootstrap-dialog.js

This adds possibility to define button's hot key that triggers action function when required keyCode is detected.
Andrew Ivaskevych 12 年之前
父节点
当前提交
bc1e1446de
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      js/bootstrap-dialog.js

+ 9 - 0
js/bootstrap-dialog.js

@@ -432,6 +432,15 @@ var BootstrapDialog = null;
                 }
             });
 
+            // Button hotKey
+            if (button.hotKey)
+                this.getModalDialog().on('keypress', function(event){
+                    if (!event || !event.which)
+                        return;
+                    if (event.which === button.hotKey)
+                        $button.trigger('click');
+                });
+
             return $button;
         },
         /**