How to store <TR> id value in array, when I toggle?
Posted
by James123
on Stack Overflow
See other posts from Stack Overflow
or by James123
Published on 2010-05-16T21:50:10Z
Indexed on
2010/05/16
23:10 UTC
Read the original article
Hit count: 172
jQuery
|JavaScript
I am toggling 'tr.subCategory1'
and its siblings .RegText
. at the same time I am trying to store its ids in the array like this list_Visible_Ids[$(this).attr('id')] = $(this).css('display') != 'none' ? 1 : null;
(When I collapsed I need store 'null'
in array at its id place, If I expand I need store I need store 1
at its id place). But everytime alert($(this).css('display'))
showing block
. How can I handle this?. So When I collapsed or expanded it is storing 1
only.
$(document).ready(function() {
$('tr[@class^=RegText]').hide().children('td');
list_Visible_Ids = [];
var idsString, idsArray;
idsString = $('#myVisibleRows').val();
idsArray = idsString.split(',');
$.each(idsArray, function() {
if (this != "" || this != null) {
$('#' + this).siblings('.RegText').toggle();
list_Visible_Ids[this] = 1;
}
});
$('tr.subCategory1')
.css("cursor", "pointer")
.attr("title", "Click to expand/collapse")
.click(function() {
$(this).siblings('.RegText').toggle();
$(this).siblings('.VolumeRegText').toggle();
//alert($(this).css('display'))
list_Visible_Ids[$(this).attr('id')] = $(this).css('display') != 'none' ? 1 : null;
});
$('#form1').submit(function() {
idsString = '';
for (var index in list_Visible_Ids) {
idsString += (idsString != '' ? ',' : '') + index;
}
$('#myVisibleRows').val(idsString);
form1.submit();
});
});
© Stack Overflow or respective owner