diff --git a/code/forms/gridfield/GridFieldAddByDBField.php b/code/forms/gridfield/GridFieldAddByDBField.php index ecd6e6e..8e6323a 100644 --- a/code/forms/gridfield/GridFieldAddByDBField.php +++ b/code/forms/gridfield/GridFieldAddByDBField.php @@ -147,6 +147,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP */ public function getHTMLFragments($gridField) { + Requirements::javascript(BLOGGER_DIR . '/js/gridfieldaddbydbfield.js'); + /** * @var DataList $dataList */ @@ -184,7 +186,6 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP 'add', 'add' ); - $addAction->setAttribute('data-icon', 'add'); $forTemplate = new ArrayData(array()); diff --git a/js/gridfieldaddbydbfield.js b/js/gridfieldaddbydbfield.js new file mode 100644 index 0000000..f6d31e2 --- /dev/null +++ b/js/gridfieldaddbydbfield.js @@ -0,0 +1,20 @@ +(function ($) { + + $.entwine('ss', function ($) { + + /** + * Prevent the CMS hijacking the return key + */ + $('.add-existing-autocompleter input.text').entwine({ + 'onkeydown': function (e) { + if(e.which == 13) { + $parent = $(this).parents('.add-existing-autocompleter'); + $parent.find('button[type="submit"]').click(); + return false; + } + } + }); + + }); + +})(jQuery);