tags:

views:

38

answers:

2

I have set of DIVs and i render CheckBoxList in each of them. Number of DIVs and number of CheckBoxLists are dynamic. Each div has a button associated with it which will toggle the visibility of that particular DIV.

Every time user clicks on a checkbox, i need to display the text of that checkbox in one label. I am thinking that i shud attach an event on the DIV's toggle event so that when the div becomes visible, i can bind a function on the click event of checkboxes inside that div which will display the text of clicked checkbox.

I am struggling to find a way to capture when the div becomes visible or invisible. How do i know which div is being displayed at a given time?

Is there any other way to do this?

A: 

You can check to see whether a div is visible or not on startup or at intervals.

this selector will tell you that.

after that you need to keep track of who is hiding it and have it call a function i think

@bauer's link would work i think but would possibly be expensive.

if this is not what you want then please expand your question.

griegs
A: 

If you want to bind event handler / actions to them at any instance:

$("div#theContainerId").find(":visible").each(function(/*Do Something*/));

If you want to bind some other action (other than hide/show) during the toggle(), do this:

$(".toggleTarget").toggle(function(){$(this).hide(); /* add more actions here */}, function(){$(this).show(); /* add more actions here */});
Yman
$(".toggleTarget").toggle(function(){$(this).hide(); /* Here i will find the checkboxes inside toggleTarget and bind event handlers to them*/},Thanks a lot.....
Asdfg