我正在使用Ajax分页,它工作正常并以手风琴显示数据。手风琴第一次工作正常,但是当我点击任何按钮(下一个,上一个,1,2或3个)时,数据被检索并以手风琴显示但是,手风琴项目没有扩展(因为它是第一次)。
这是代码,
对于控制器
insert_equal
视图代码(主要产品和服务页面)
function productandservice() {
$config = array();
$config["base_url"] = base_url() . "home/productandservice";
$config["total_rows"] = $this->user->prod_count();
$config["per_page"] = 2;
$config["uri_segment"] = 3;
$config['use_page_numbers'] = TRUE;
$config['cur_tag_open'] = ' ';
$config['cur_tag_close'] = '';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["results"] = $this->user->fetch_prod($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
if($this->input->post('ajax')) {
$this->load->view('ciajaxpagination',$data);
}
else {
$data['dropdown'] = $this->user->getcategory();
$this->load->view('user/product-service',$data);
}
//$data['view_file'] = 'user/product-service';
//$data['result'] = $result;
}
和ciajaxpagination.php的代码
<div class="span12">
<div class="accordion" id="ajaxdata">
<?php
foreach($results as $data) {
echo "<div class='accordion-item'>";
echo "<a class='accordion-item-toggle' href='#' style='color:#fff'>".$data->name."</a>";
echo "<div class='accordion-item-content fixed' style='display: none;'>";
echo "<div class='span4'>";
echo "<img src='_content/index/slider/slider-3-p1.png' alt='sample product-service'></div>";
echo "<div class='8'>";
echo "Description:<p>".$data->description."</p>";
echo "Keywords:<p>".$data->keywords."</p>";
//echo $data->name . " - " . $data->description . "<br>";
echo "<p><a class='btn btn-orange' id='btnedit-product' href='#edit-product'>Edit</a> <a class='btn btn-orange' href='#'>Delete</a></p>";
echo "</div></div><div>";
}
?>
<div class="accordion-item" >
<a class="accordion-item-toggle" href="#" style="color:#fff"> Product/Service 1</a>
<div class="accordion-item-content fixed" style="display: none;">
<div class="span4">
<img src="_content/index/slider/slider-3-p1.png" alt="sample product-service">
</div>
<div class="8">Description:<p> Duis sed quam risus. Vivamus ultrices et risus id hendrerit. Etiam quam diam, imperdiet ac euismod in, scelerisque vitae libero. Nullam vitae tempus est. Sed ullamcorper, odio a egestas porta, urna urna elementum dui, at lacinia.</p>
Keywords : <p>keyword1, keyword2, keyword3, keyword4, keyword5</p>
<p><a class="btn btn-orange" id="btnedit-product" href="#edit-product">Edit</a> <a class="btn btn-orange" href="#">Delete</a></p>
</div>
</div>
</div>
<div class="pagination" id="ajax_pagingsearc">
<p><?php echo $links; ?></p>
</div>
</div>
</div>
这是用于通过ajax
调用数据的函数<?php
foreach($results as $data) {
echo "<div class='accordion-item'>";
echo "<a class='accordion-item-toggle' href='#' style='color:#fff'>".$data->name."</a>";
echo "<div class='accordion-item-content fixed' style='display: none;'>";
echo "<div class='span4'>";
echo "<img src='_content/index/slider/slider-3-p1.png' alt='sample product-service'></div>";
echo "<div class='8'>";
echo "Description:<p>".$data->description."</p>";
echo "Keywords:<p>".$data->keywords."</p>";
//echo $data->name . " - " . $data->description . "<br>";
echo "<p><a class='btn btn-orange' id='btnedit-product' href='#edit-product'>Edit</a> <a class='btn btn-orange' href='#'>Delete</a></p>";
echo "</div></div></div>";
}
?>
<div class="pagination" id="ajax_pagingsearc">
<p><?php echo $links; ?></p>
</div>
你可以看到现场demo, (查看第二个标签产品和服务列表)
请尽快帮我解决这个问题
注意:首先使用给定的凭据登录
用户名:vishal@gmail.com /密码:密码
只有这样才能加载该用户的产品。