Last active
May 1, 2017 21:56
-
-
Save jodyHamilton/d0ecea3f2194429bc6b444fc56fcbccd to your computer and use it in GitHub Desktop.
Drupal 8 inline_form_errors with field_group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inline_form_errors module gives links to elements with errors. | |
// When using field_group module (this is for vertical tabs) you need to first open the right vertical tab | |
// and then scroll to the element with the error. | |
$('.messages__list a', context).on('click', function(e) { | |
var url = $(this).attr('href'); | |
var hash = url.substring(url.indexOf('#')); | |
var index = $(hash).parents('.vertical-tabs__pane').index() - 1; | |
if (index >= 0) { | |
$('ul.vertical-tabs__menu li').eq(index).find('a').click(); | |
} | |
$('html, body').animate({ | |
scrollTop: $(hash).parent().offset().top-150 | |
}, 500); | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment