dongyied24121 2013-08-01 02:03
浏览 443
已采纳

如何使用ajax加载<a href="">标记的值

I'm working with Codeigniter Calendar Class library and I want the "next month" and "previous month" button work without reloading the page, just refresh the month.

In my Model I've created the calendar template with the following configuration:

        $this->conf = array(
            'start_day' => 'monday',
            'show_next_prev' => true,
            'next_prev_url' => base_url().'index.php/admin/reservation'             
        );
    $this->conf['template'] = '

     {table_open}<table border="0" cellpadding="0" cellspacing="0"class="calendar">{/table_open}

       {heading_row_start}<tr>{/heading_row_start}

       {heading_previous_cell}<th class="prev_button"><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
       {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
       {heading_next_cell}<th class="next_button"><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}

       {heading_row_end}</tr>{/heading_row_end}

       {week_row_start}<tr>{/week_row_start}
       {week_day_cell}<td>{week_day}</td>{/week_day_cell}
       {week_row_end}</tr>{/week_row_end}

       {cal_row_start}<tr class="days">{/cal_row_start}
       {cal_cell_start}<td>{/cal_cell_start}

       {cal_cell_content}
            <div class="day_num">{day}</div>
            <div class="content">{content}</div>
       {/cal_cell_content}
       {cal_cell_content_today}
            <div class="day_num highlight">{day}</div>
            <div class="content">{content}</div>
       {/cal_cell_content_today}

       {cal_cell_no_content}
            <div class="day_num">{day}</div>
        {/cal_cell_no_content}
       {cal_cell_no_content_today}
            <div class="day_num highlight">{day}</div>
       {/cal_cell_no_content_today}

       {cal_cell_blank}&nbsp;{/cal_cell_blank}

       {cal_cell_end}</td>{/cal_cell_end}
       {cal_row_end}</tr>{/cal_row_end}

       {table_close}</table>{/table_close}

And in my View:

 <script type="text/javascript">
    $(document).ready(function(){
        $('.next_button').click(function(){
            alert("working");
        });         
    });     

</script>

I just really don't know on how to load the value of the class "prev_button" and "next_button" in my calendar template. So please help!

  • 写回答

3条回答 默认 最新

  • doujiacai4986 2013-08-02 06:49
    关注

    Finally found the solution. See below:

        <script>
        $(document).ready(function(){       
        $(document).on('click','.next_button', function() {
            var href = $(this).find('a').attr('href');
            $.post(href, { }, function(data){
                $('#calendar').html(data);
            })
    
            return false;
        });
    
        $(document).on('click','.prev_button', function() {
            var href = $(this).find('a').attr('href');
            $.post(href, { }, function(data){
                $('#calendar').html(data);
            })
    
            return false;
        });
    
       });
       </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?