You are calling BindTimeSelectors before the AJAX load is complete.

Which AJAX load is the one that BindTimeSelectors depends on? Assuming it is
the second one, you could code it like this:

 $("#daysheader").load( "ajax/weekview_headers.aspx?fromdate=" +
calendarDay.Date );
 $("#days").load(
     "ajax/weekview_appointments.aspx?fromdate=" + calendarDay.Date,
     BindTimeSelectors()
 );

Also, the code that wires up the events could be simplified considerably.
Are you able to give each of those DOM elements a common class name? If they
all have the class name "dayselector" then you could just code:

 function BindTimeSelectors()
 {
     //Wire up mouse down events to the day selectors.
     $(".dayselector").mousedown( function() { mouseDown( this.id ); } );
 }

If you can't do that, a simple loop would do the trick:

 function BindTimeSelectors()
 {
     //Wire up mouse down events to the day selectors.
     for( var i = 1;  i <= 5;  i++ ) {
         $( "#day" + i + "selector" ).mousedown( function() { mouseDown(
this.id ); } );
     }
 }

> I'm loading some DIV in to a container DIV using AJAX... all 
> works like a charm. However, I need to bind some events to 
> the DIVs I'm dynamically loading in, no joy :(
> 
> I guess I need to refresh the DOM somehow?
> 
> My code looks like:
> 
> $("#daysheader").load("ajax/weekview_headers.aspx?fromdate=" +
calendarDay.Date);
> $("#days").load("ajax/weekview_appointments.aspx?fromdate=" +
calendarDay.Date);
> BindTimeSelectors();
> 
> function BindTimeSelectors()
> {
>     //Wire up mouse down events to the day selectors.
>     $("#day1selector").mousedown(function(){mouseDown("day1selector");});
>     $("#day2selector").mousedown(function(){mouseDown("day2selector");});
>     $("#day3selector").mousedown(function(){mouseDown("day3selector");});
>     $("#day4selector").mousedown(function(){mouseDown("day4selector");});
>     $("#day5selector").mousedown(function(){mouseDown("day5selector");});
> }


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to