Avoid unneeded DOM traversal

Avoid unneeded wrapping of a jQuery object
This commit is contained in:
Marc Delisle
2011-02-04 13:05:54 -05:00
parent a6f5f95600
commit d17b0e157d

View File

@@ -114,28 +114,30 @@ $(document).ready(function() {
$('.drop_primary_key_index_anchor').live('click', function(event) { $('.drop_primary_key_index_anchor').live('click', function(event) {
event.preventDefault(); event.preventDefault();
$anchor = $(this);
/** /**
* @var curr_row Object containing reference to the current field's row * @var $curr_row Object containing reference to the current field's row
*/ */
var curr_row = $(this).parents('tr'); var $curr_row = $anchor.parents('tr');
/** @var Number of columns in the key */ /** @var Number of columns in the key */
var rows = $(this).parents('td').attr('rowspan') || 1; var rows = $anchor.parents('td').attr('rowspan') || 1;
/** @var Rows that should be hidden */ /** @var Rows that should be hidden */
var rows_to_hide = curr_row; var $rows_to_hide = $curr_row;
for (var i = 1, last_row = curr_row.next(); i < rows; i++, last_row = last_row.next()) { for (var i = 1, $last_row = $curr_row.next(); i < rows; i++, $last_row = $last_row.next()) {
rows_to_hide = rows_to_hide.add(last_row); $rows_to_hide = $rows_to_hide.add($last_row);
} }
var question = $(curr_row).children('td').children('.drop_primary_key_index_msg').val(); var question = $curr_row.children('td').children('.drop_primary_key_index_msg').val();
$(this).PMA_confirm(question, $(this).attr('href'), function(url) { $anchor.PMA_confirm(question, $anchor.attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strDroppingPrimaryKeyIndex']); PMA_ajaxShowMessage(PMA_messages['strDroppingPrimaryKeyIndex']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) { if(data.success == true) {
PMA_ajaxShowMessage(data.message); PMA_ajaxShowMessage(data.message);
rows_to_hide.hide("medium").remove(); $rows_to_hide.hide("medium").remove();
} }
else { else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);