The filter on textfield did not do the intended result, it was catching

other input elements;
Unneeded wrapping of jQuery objects
Prefix jQuery objects with dollar sign
This commit is contained in:
Marc Delisle
2011-01-01 09:38:33 -05:00
parent 20619dd544
commit 1b0116ba3b

View File

@@ -362,9 +362,9 @@ $(document).ready(function() {
while( curr_rows < target_rows ) { while( curr_rows < target_rows ) {
/** /**
* @var last_row Object referring to the last row * @var $last_row Object referring to the last row
*/ */
var last_row = $("#insertForm").find(".insertRowTable:last"); var $last_row = $("#insertForm").find(".insertRowTable:last");
// need to access this at more than one level // need to access this at more than one level
// (also needs improvement because it should be calculated // (also needs improvement because it should be calculated
@@ -372,12 +372,13 @@ $(document).ready(function() {
var new_row_index = 0; var new_row_index = 0;
//Clone the insert tables //Clone the insert tables
$(last_row) $last_row
.clone() .clone()
.insertBefore("#actions_panel") .insertBefore("#actions_panel")
.find('input[name*=multi_edit],select[name*=multi_edit]') .find('input[name*=multi_edit],select[name*=multi_edit]')
.each(function() { .each(function() {
var $this_element = $(this);
/** /**
* Extract the index from the name attribute for all input/select fields and increment it * Extract the index from the name attribute for all input/select fields and increment it
* name is of format funcs[multi_edit][10][<long random string of alphanum chars>] * name is of format funcs[multi_edit][10][<long random string of alphanum chars>]
@@ -386,7 +387,7 @@ $(document).ready(function() {
/** /**
* @var this_name String containing name of the input/select elements * @var this_name String containing name of the input/select elements
*/ */
var this_name = $(this).attr('name'); var this_name = $this_element.attr('name');
/** split {@link this_name} at [10], so we have the parts that can be concatenated later */ /** split {@link this_name} at [10], so we have the parts that can be concatenated later */
var name_parts = this_name.split(/\[\d+\]/); var name_parts = this_name.split(/\[\d+\]/);
/** extract the [10] from {@link name_parts} */ /** extract the [10] from {@link name_parts} */
@@ -400,9 +401,10 @@ $(document).ready(function() {
var new_name = name_parts[0] + '[' + new_row_index + ']' + name_parts[1]; var new_name = name_parts[0] + '[' + new_row_index + ']' + name_parts[1];
var hashed_field = name_parts[1].match(/\[(.+)\]/)[1]; var hashed_field = name_parts[1].match(/\[(.+)\]/)[1];
$(this).attr('name', new_name); $this_element.attr('name', new_name);
$(this).filter('.textfield') if ($this_element.is('.textfield')) {
$this_element
.attr('value', '') .attr('value', '')
.unbind('change') .unbind('change')
.attr('onchange', null) .attr('onchange', null)
@@ -410,22 +412,23 @@ $(document).ready(function() {
Validator( Validator(
hashed_field, hashed_field,
new_row_index, new_row_index,
$(this).closest('tr').find('span.column_type').html() $this_element.closest('tr').find('span.column_type').html()
); );
}) });
.end(); }
$(this).filter('.checkbox_null') if ($this_element.is('.checkbox_null')) {
$this_element
.bind('click', function(e) { .bind('click', function(e) {
nullify( nullify(
$(this).siblings('.nullify_code').val(), $this_element.siblings('.nullify_code').val(),
$(this).closest('tr').find('input:hidden').first().val(), $this_element.closest('tr').find('input:hidden').first().val(),
hashed_field, hashed_field,
'[multi_edit][' + new_row_index + ']' '[multi_edit][' + new_row_index + ']'
); );
}) });
.end(); }
}) }) // end each
.end() .end()
.find('.foreign_values_anchor') .find('.foreign_values_anchor')
.each(function() { .each(function() {