Skip to content

Commit 00a084e

Browse files
committed
feat(modal): support input[autofocus] (fixes mgcrea#80)
1 parent 646956c commit 00a084e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/directives/modal.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ angular.module('$strap.directives')
3939
});
4040

4141
// Provide scope display functions
42-
scope._modal = function(name) {
42+
scope.$modal = function(name) {
4343
$modal.modal(name);
4444
};
4545
scope.hide = function() {
@@ -50,20 +50,18 @@ angular.module('$strap.directives')
5050
};
5151
scope.dismiss = scope.hide;
5252

53-
$modal.on("show", function(event) {
54-
scope.$emit("modal-show", event);
53+
$modal.on('show', function(event) {
54+
scope.$emit('modal-show', event);
5555
});
56-
57-
$modal.on("shown", function(event) {
58-
scope.$emit("modal-shown", event);
56+
$modal.on('shown', function(event) {
57+
scope.$emit('modal-shown', event);
58+
$('input[autofocus]').first().trigger('focus');
5959
});
60-
61-
$modal.on("hide", function(event) {
62-
scope.$emit("modal-hide", event);
60+
$modal.on('hide', function(event) {
61+
scope.$emit('modal-hide', event);
6362
});
64-
65-
$modal.on("hidden", function(event) {
66-
scope.$emit("modal-hidden", event);
63+
$modal.on('hidden', function(event) {
64+
scope.$emit('modal-hidden', event);
6765
});
6866

6967
});

0 commit comments

Comments
 (0)