Merge pull request #371 from micmania1/266-fix-cms-hijacking-keypress

FIX Prevent the CMS Hijacking the return keypress in gridfieldaddbydb…
This commit is contained in:
Damian Mooyman 2016-02-09 14:31:50 +13:00
commit 17429c043f
2 changed files with 22 additions and 1 deletions

View File

@ -147,6 +147,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
*/ */
public function getHTMLFragments($gridField) public function getHTMLFragments($gridField)
{ {
Requirements::javascript(BLOGGER_DIR . '/js/gridfieldaddbydbfield.js');
/** /**
* @var DataList $dataList * @var DataList $dataList
*/ */
@ -184,7 +186,6 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
'add', 'add',
'add' 'add'
); );
$addAction->setAttribute('data-icon', 'add'); $addAction->setAttribute('data-icon', 'add');
$forTemplate = new ArrayData(array()); $forTemplate = new ArrayData(array());

View File

@ -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);