views:

42

answers:

3

Hi all, I'm busy to create an online agenda. I have 3 drop down menu's where you can select the year, month and week you want to see. Then with out a page refresh the div's(day's with there number for example you selected februari 2008 and you get 1 feb thuiesday ect..) are printed. Those divs must be made click able so a popup/light box will open the selected day with the apointments. (the divs are an callback form handler.php and there 35 of them so i hope i can do it with one function)

i made a function called test and added that on the onlclick event but it dindt work(but the alert was shown when i started the page and hadn't posted or cliked anything)

$(function test(){alert("test");

and i made all div's the same class(klik) so that if something with the class klik is cliked that the alert ad to be shown but also that dint work .

$('.klik').click(function(){ alert("test"); });});

the css of the divs:

div#a1 { width:100px; height:110px; margin-left:99px; margin-top:-111px; border-bottom: 1px solid black; border-left: 1px solid black; cursor:pointer; display:block; }

the creation of the divs in handler.php `$b=0;

            while ($b < 35)
                    {
  echo "<div id='a$b' name='b' class='klik'>";
  echo "<p>test ".$b."" ;
  echo "</div>";
  $b++;
  }`

I hope i gave u enough information that mabey you guys can help me thanks Mark

+1  A: 

Hi, is your function to make the divs clickable in the onload event ?

$(document).ready(function() {
   $('.klik').click(function(){ alert("test"); });}); 
});
ArneRie
+3  A: 

Look into event delegation, which is implemented in jQuery as Events/live.

So, instead of

$('.klik').click(function() { alert('test'); });

try

$('.klik').live('click', function() { alert('test'); });
bryan
This was what I was about to suggest
Chris
A: 

thank you brian that was what i was searching for!!!!