Make autofocus textbox module

This commit adds a very small Javascript module to autofocus a textbox on page
load. It should only be used once per page.

It also adds a parameter to the textbox macro which adds the attribute to
trigger autofocus.
This commit is contained in:
Chris Hill-Scott
2016-02-02 16:16:29 +00:00
parent 9767ee1511
commit 776539462e
3 changed files with 23 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
(function(Modules) {
"use strict";
Modules.Autofocus = function() {
this.start = function(component) {
$('input, textarea, select', component).eq(0).trigger('focus');
};
};
})(window.GOVUK.Modules);