Код: Выделить всё
public function actionAjaxList(){
if(Yii::app()->request->isAjaxRequest)
{
$goodsCart = Yii::app()->shoppingCart->getPositions();
//var_dump($goodsCart);exit();
$items=array();
foreach ($goodsCart as $key => $value){
//var_dump($value);exit();
$item=array(
'id' => $value->attributes['index'],
'name' => $value->attributes['name'],
'img' => $value->attributes['image1'],
'artno' => $value->attributes['artno'],
'category' => $value->imgPath,
'subcategory' => $value->attributes['category'],
);
$items[]=$item;
}
echo CJSON::encode($items);
}
}
Код: Выделить всё
$('.item-b2.card').on({
mouseenter: function(){
$(this).attr('class','item-b2 card active');
var drop_list='<div class="card-drop"><div class="top-drop"></div><div class="main-drop"></div><div class="bottom-drop"></div></div>';
$(this).append(drop_list);
$.ajax({
type: "POST",
url: 'cart/ajaxList',
data: '',
success: function (message) {
// alert(message);
var obj = jQuery.parseJSON(message);
console.log(obj);
for(var i=0;i<data.length;i++){
var element='<div class="element-cart-drop">\n\
<div class="element-cart-drop-img"><img src="'+data.img+'" width="70" height="70"/></div>\n\
<div class="element-cart-drop-desk"></div>\n\
<div class="element-cart-drop-del"></div>\n\
</div>';
$('.card-drop .main-drop').append(element);
}
}
});
//$('.card-drop .main-drop').html();
//console.log('start');
},
mouseleave: function(){
$(this).attr('class','item-b2 card');
$('.card-drop').remove();
//console.log('end');
}
}); // desc