From 0e97213792b462ae4f185c398c0278851bdecb55 Mon Sep 17 00:00:00 2001 From: nod_ Date: Fri, 31 Aug 2012 10:30:55 +0200 Subject: [PATCH] Issue #1764976 by nod_: Fixed views-list.js. --- js/views-list.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/js/views-list.js b/js/views-list.js index fbf05943b8d..6932d0dbacd 100644 --- a/js/views-list.js +++ b/js/views-list.js @@ -2,21 +2,31 @@ * @file * Javascript related to the main view list. */ -(function ($) { +(function ($, Drupal) { "use strict"; Drupal.behaviors.viewsUIList = { - attach: function (context) { - $('#ctools-export-ui-list-items thead a').once('views-ajax-processed').each(function() { - $(this).click(function() { + attach: function () { + var $itemsTable = $('#ctools-export-ui-list-items thead').once('views-ajax-processed'); + var $itemsForm = $('#ctools-export-ui-list-form'); + if ($itemsTable.length) { + $itemsTable.on('click', 'a', function (e) { + e.preventDefault(); var query = $.deparam.querystring(this.href); - $('#ctools-export-ui-list-form select[name=order]').val(query.order); - $('#ctools-export-ui-list-form select[name=sort]').val(query.sort); - $('#ctools-export-ui-list-form input.ctools-auto-submit-click').trigger('click'); - event.preventDefault(); + $itemsForm.find('select[name=order]').val(query.order); + $itemsForm.find('select[name=sort]').val(query.sort); + $itemsForm.find('input.ctools-auto-submit-click').trigger('click'); }); - }); + } + }, + detach: function (context, settings, trigger) { + if (trigger === 'unload') { + var $itemsTable = $('#ctools-export-ui-list-items thead').removeOnce('views-ajax-processed'); + if ($itemsTable.length) { + $itemsTable.off('click'); + } + } } };