0

在 pyrocms 中,我有一个列表视图,我使用 Jquery Ajax 过滤记录。我使用灯箱显示的每条记录都附有图像。当页面首先加载时它工作正常,但是当我使用过滤时,我得到了正确的图像和链接 html,但是当我将该 html 放在视图上时,它得到了改变

<a href="http://localhost/pyrocms/upload/2_LBergereChairWU2-1.jpg" class="lightbox cboxElement">
<img src="http://localhost/pyrocms/upload/2_LBergereChairWU2-1.jpg" height="20" width="20">
</a>

对此

 <a href="http://localhost/pyrocms/upload/2_LBergereChairWU2-1.jpg" class="lightbox cboxElement"></a>
<img src="http://localhost/pyrocms/upload/2_LBergereChairWU2-1.jpg" height="20" width="20">

有什么问题请帮忙...

这是我的jQuery代码

 $('#nameSearch').click(function(){
var name =$('#name').val();
$.ajax({
        type:"POST",
        url:"admin/inventory_items/filter",
        data:"name="+name,
        success:function(html){
            $('#itemsfilter').html(html);
        }
    })
    return false;
 });

这是我的过滤方法

 public function filter() {
    if(isset($_REQUEST['catagory'])){$cat = $_REQUEST['catagory']; $items = $this->inventory_items_m->getoncat($cat);}
    if(isset($_REQUEST['subcatagory'])){$subcat = $_REQUEST['subcatagory']; $items = $this->inventory_items_m->getonsubcat($subcat);}
    if(isset($_REQUEST['name'])){$name = $_REQUEST['name']; $items = $this->inventory_items_m->getonname($name);}
    $catagories = $this->inventory_catagories_m->get_catagories();
    $subcatagories = $this->inventory_subcatagories_m->get_subcatagories();
    $images = $this->inventory_items_m->getimages();
    foreach ($items->result() as $item) {
        echo "<tr>";
                 echo "<td>"; echo $item->id; echo "</td>";
                 echo "<td>";
                   //for images
                $img = NULL; $i=0;

                foreach ($images->result() as $image) {

                        if($image->id == $item->id){
                            $img[$i] = $image->filename;
                            $i++;
                            }


                    }
                    $num = count($img);

                if($num>0):
                  for($j=0; $j<1; $j++) { 
                    echo "<a href=\"".site_url()."upload/".$img[($j)]."\" class='lightbox cboxElement' />";
                        echo "<img src=\"".site_url().'upload/'.$img[($j)]."\"  height=\"20\" width=\"20\" />";
                    echo "</a>";
                    }


                endif;
               echo "</td>";
               echo "<td>"; echo $item->name; echo "</td>";
               echo "<td>"; echo $item->desc; echo "</td>";
               echo "<td>"; echo $item->no_of_items; echo "</td>";


                //for name of catagory
                foreach ($catagories as $catagory) {
                        if($catagory->id == $item->catagory) {
                            $catagoryname = $catagory->name;
                        }
                    }


                //<!-- for name of subcatagory -->
                foreach ($subcatagories as $subcatagory) {
                        if($subcatagory->id == $item->subcatagory) {
                            $subcatagoryname = $subcatagory->name;
                        }
                    }




                echo "<td>"; echo @$catagoryname; "</td>";
                echo "<td>"; echo @$subcatagoryname; "</td>";
                echo "<td class=\"actions\" style=\"width: 325px;\">";
                echo "<div class=\"buttons\">";                
                echo anchor('admin/inventory_items/uploadImages/'.$item->id, lang('button.img'),'class="button edit"')." ";
                echo anchor('admin/inventory_items/addnotes/'.$item->id, lang('button.notes'),'class="button edit"')." ";
                echo anchor('admin/inventory_items/edit/'.$item->id.'/'.$item->catagory.'/'.$item->subcatagory, lang('buttons.edit'), 'class="button edit"')." ";
                echo anchor('admin/inventory_items/delete/'.$item->id, lang('buttons.delete'), 'class="confirm button delete"'); 
                echo "</div>";
                echo "</td>";
            echo "</tr>";
    }


}

现在请检查

4

1 回答 1

0

好的,我得到了答案,我在锚标记中有一个额外的斜线

echo "<a href=\"".site_url()."upload/".$img[($j)]."\" class='lightbox cboxElement' />";

只是删除“>”之前的最后一个斜线解决了我的问题无论如何thanx Mr NullPointer

于 2013-01-01T09:40:53.697 回答