views:

46

answers:

1

I am toggling row siblings. I wrote .toggle(true) when document ready. see below picture. I think row sibling are not availble before this function calls.

alt text

 $(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).siblings('.RegText').toggle(true);
                list_Visible_Ids[this] = 1;
            }
        });

alt text

alt text

How to resolve this? why sliblings are not avaible in when document is ready?

+4  A: 

Your posted code doesn't match the debugger code, your code has this, which is (almost!) correct:

$(this).siblings('.RegText').toggle(true);

The debugger has this, which is incorrect:

$(this).siblings(('.RegText').toggle(true));

You need to update whatever you're actually debugging to that code without the extra parenthesis, otherwise you're going to get some pretty funky behavior there.

Also you need a # in there since your debugger shows you're not storing the hash mark in the array, which is perfectly fine. You're currently calling $("row10") (which looks for <row10> elements), but what you need is $("#row10") (which looks for id="row10" elements), so adjust your call like this:

$('#' + this).siblings('.RegText').toggle(true);
Nick Craver
I works good for me. Thanks Nick. But I am loosing .css (font mismatch).Why font is missing?
James123