diff --git a/core/modules/views_ui/js/views_ui.listing.js b/core/modules/views_ui/js/views_ui.listing.js index b9386c5..9e92a1e 100644 --- a/core/modules/views_ui/js/views_ui.listing.js +++ b/core/modules/views_ui/js/views_ui.listing.js @@ -51,23 +51,24 @@ } }; - //Enable button fix + // Enable button fix. Drupal.behaviors.viewsEnableFocus = { attach: function (context, settings) { - $('tr.views-ui-list-disabled li.enable .use-ajax', context).on('click', function(){ + $('tr.views-ui-list-disabled li.enable .use-ajax', context).on('click', function() { // Get element title. var title = $(this).closest('tr').attr('title'); // Listen for changes on upper DOM lists - var interval=setInterval(function() { - var trs = $('tr.views-ui-list-enabled'); - trs.each(function(i) { - // If upper DOM gets updated get element(based on title) and focus it. - if( $(this).attr('title') == title ){ - $(this).find('a').focus(); + var interval = setInterval(function() { + $('tr.views-ui-list-enabled').each(function() { + var $this = $(this); + // If upper DOM gets updated get element(based on title) + // and focus it. + if($this.attr('title') == title) { + $this.find('a').focus(); clearInterval(interval); } }); - },500); + }, 500); }); } };