-1

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?

Asdfg
  • 11,362
  • 24
  • 98
  • 175
  • What excactly do you mean with toggled? – dst Aug 04 '10 at 05:38
  • What "toggling" are you talking about? You mean the visibility? If so, see: http://stackoverflow.com/questions/941113/jquery-javascript-dom-visibility-event – gpmcadam Aug 04 '10 at 05:40
  • I am talking abt making div show or hide by calling .toggle() event. – Asdfg Aug 04 '10 at 06:13
  • @Bauer: It does what i want to do but i am looking for the native code. I think if JQuery gives toggle functionality then there shud be a way to attach a function to it too. – Asdfg Aug 04 '10 at 06:16

2 Answers2

0

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
  • 22,624
  • 33
  • 128
  • 205
0

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
  • 934
  • 8
  • 16
  • $(".toggleTarget").toggle(function(){$(this).hide(); /* Here i will find the checkboxes inside toggleTarget and bind event handlers to them*/}, Thanks a lot..... – Asdfg Aug 05 '10 at 08:18