Welcome Guest, Not a member yet? Register   Sign In
Ajax stops working after first click
#1

[eluser]bondjp[/eluser]
So my problem is that ajax only works when i click "nextweeklink" link for the first time, it updates the table with next week's appointments and then stops working when i try and click again "nextweeklink" but firebug says script was OK.
Thanks

ResultsView
Code:
[removed]
$(document).ready(function(){
        $(function () {
    
    $('#nextweeklink').livequery('click',function() {
                
    $('<div id="resultdr">').load('searchresults/ajax_nextweek #result_dr', function() {
    $(this).hide('#resultdr').replaceAll('#resultdr') ;
       });
     return false;
      });
});    
[removed]
&lt;/head&gt;
&lt;body&gt;
............
<div id="resultdr">    
<hr>
<table class="search_results" id="search_results" >
    <thead id="thead">
    <tr class="table_head" id="table_head">
             &lt;?php $weekdates=substr($WeekDate[1],8,2);
             if ($weekdates>$lowEnd){?&gt;
             <th class="prev_week" id="prev_week">
                 <a class="prevWeekLink" id="prevweeklink" rel="nofollow" title="search prev week">Prev. Week</a>
            </th>
            &lt;?php } else {?&gt;
        <th>
        </th>
        &lt;?php }?&gt;
                    
        <th class="calendar">
            <span  class="day">Monday</span>
            <span class="date">&lt;?php echo $WeekDate[1];?&gt;</span>
        </th>
        <th class="calendar">
        <span class="day">Tuesday</span>
        <span class="date">&lt;?php echo $WeekDate[2];?&gt;</span>
        </th>
        
..............................................            
                    
        <th class="next_week">
        <a class="nextWeekLink" id="nextweeklink" rel="nofollow" title="search next week">Next Week</a>
        </th>
    </tr>
    </thead>    

    &lt;?php foreach($docs as $row):
            
            $name=$row->name;
            $addr=$row->address;
            $doc_id=$row->doctor_id;
            
        
    <tbody>
        <tr>
        <td class="calendar" id="calendar" rowspan="1">
        </td>
        <td class="calendar alt" id="monday" rowspan="1">
        <div>
        &lt;?php
        //get appointments
        foreach($timeslots as $row):
        $date=$row->data;
        $docid=$row->doctor_id;
        $date = substr($date, 0, 10);
        if ($doc_id==$docid){
        if ($WeekDate[1]==$date){?&gt;
            <center>
            &lt;?php
            $date=$row->data;
            $date=substr($date,11,5);
            echo anchor ($date,$date);?&gt;
            </center>
        &lt;?php    }
        }
        endforeach;?&gt;    
        </div>
        </td>
        <td class="calendar"  id="tuesday" rowspan="1">
        <div>
        &lt;?php
        foreach($timeslots as $row):
        $date=$row->data;
        $docid=$row->doctor_id;
        $date = substr($date, 0, 10);
        if ($doc_id==$docid){
        if ($WeekDate[2]==$date){?&gt;
            <center>
            &lt;?php
            $date=$row->data;
            $date=substr($date,11,5);
            echo anchor ($date,$date);?&gt;
            </center>
        &lt;?php    }
        }
        endforeach;?&gt;    
        </div>
        </td>
........................................

    </tr>    
    </tbody>
        &lt;?php endforeach;?&gt;
</table>
&lt;?php echo $this->pagination->create_links(); ?&gt;
</div>

ajax_nextweek Controller
Code:
//pagination
.............
$this->pagination->initialize($config);
    //get the day number for calculating next week
    $query=$this->uri->segment(3);
        $data['datas']=$this->Results->getDatasNextweek($query);
......................        
        $this->load->vars($data);
        $this->load->view('ajax_timeslots', $data);
        
    }


Ajaxview - ajax_timeslots view (It will replace my calendar appointments)
Code:
<div id="result_dr">
&lt;?php foreach($datas as $row):
        $datais=$row;//current day value from ajax_nextweek controller
    endforeach;?&gt;    
        &lt;?php    //calculate day of the week
        //$lowEnd=date("w");
        $lowEnd=$datais;
        $highEnd=$lowEnd+7;
        $weekday=0;
        for ($i=$lowEnd; $i<=$highEnd; $i++) {
            $WeekDate[$weekday]=date("Y-m-d",mktime(0, 0, 0, date("m")  , date("d")+$i, date("Y")));
            $weekday++;
        }
     ?&gt;
<table class="search_results" id="search_results" >
    <thead id="thead">
    <tr class="table_head" id="table_head">
             &lt;?php $weekdates=substr($WeekDate[1],8,2);
             if ($weekdates>$lowEnd){?&gt;
             <th class="prev_week" id="prev_week">
                 <a class="prevWeekLink" id="prevweeklink" rel="nofollow" title="search prev week">Prev. Week</a>
            </th>
            &lt;?php } else {?&gt;
        <th>
        </th>
        &lt;?php }?&gt;
                    
        <th class="calendar">
            <span  class="day">Monday</span>
            <span class="date">&lt;?php echo $WeekDate[1];?&gt;</span>
        </th>
      
..............................................            
        <th class="next_week">
        <a class="nextWeekLink" id="nextweeklink" rel="nofollow" title="search next week">Next Week</a>
        </th>
    </tr>
    </thead>    
    &lt;?php foreach($docs as $row):
          
     <tbody>
        ...........// equals to ResultsView <Tbody>
    </tbody)
     &lt;?php endforeach;?&gt;
  </table>
        &lt;?php echo $this->pagination->create_links(); ?&gt;    
</div>


Messages In This Thread
Ajax stops working after first click - by El Forum - 03-09-2010, 10:43 AM
Ajax stops working after first click - by El Forum - 03-09-2010, 10:53 AM
Ajax stops working after first click - by El Forum - 03-09-2010, 10:53 AM
Ajax stops working after first click - by El Forum - 03-09-2010, 10:55 AM
Ajax stops working after first click - by El Forum - 03-09-2010, 06:54 PM
Ajax stops working after first click - by El Forum - 03-09-2010, 07:07 PM
Ajax stops working after first click - by El Forum - 03-10-2010, 10:45 AM
Ajax stops working after first click - by El Forum - 03-10-2010, 11:07 AM
Ajax stops working after first click - by El Forum - 03-10-2010, 11:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB