Php 获取.live或.delegate或livequery插件以保持购物车的活动状态

Php 获取.live或.delegate或livequery插件以保持购物车的活动状态,php,jquery,Php,Jquery,我有一个加载了ajax的容器,我正试图让它与我的一些插件配合使用。到目前为止,我使用jquery.live成功地让scrollTo和一个lightbox在这个“死亡容器”中工作,但我喜欢的“添加到购物车”按钮没有带来好运。我已经玩了几天了。delegate,livequery插件等等,但是我真的没有足够的能力去弄清楚到底是什么。(我对自己正在做的事情了解得相当肤浅。) 这是我的购物车插件,它相当小而且简单。您是否可以就(.live、.delegate或.livequery,或者完全其他内容)应该

我有一个加载了ajax的容器,我正试图让它与我的一些插件配合使用。到目前为止,我使用jquery.live成功地让scrollTo和一个lightbox在这个“死亡容器”中工作,但我喜欢的“添加到购物车”按钮没有带来好运。我已经玩了几天了。delegate,livequery插件等等,但是我真的没有足够的能力去弄清楚到底是什么。(我对自己正在做的事情了解得相当肤浅。)

这是我的购物车插件,它相当小而且简单。您是否可以就(.live、.delegate或.livequery,或者完全其他内容)应该插入到哪里给出建议

(注意:shopme p=添加到购物车按钮,需要插入到ajax加载的“死亡容器”中。购物车的其余部分存在于所述容器之外,并且工作正常,因为它没有嵌入ajax。)

$(文档).ready(函数(){
$('.wooo').bloooming_shop();
$('body').append('hide cart shopping cart');
$('#panelcontent').hide();
$.ajax({
键入:“获取”,
url:“/wooo/cart.php”,
async:false,
数据类型:“html”,
成功:函数(html){
$('#panelcontent').html(html);
}
});
$(“.panelbutton”)。单击(函数(){
$(“#面板”)。设置动画({
高度:“200px”
},“快速”,函数(){
$('#panelcontent').show();
});
$(“#hidepanel”).fadeIn();
$(“#显示面板”).fadeOut();
}); 
$(“#隐藏面板”)。单击(函数(){
$(“#面板”)。设置动画({
高度:“0px”
},“快速”,函数(){
$(“#显示面板”).fadeIn();
$('#panelcontent').hide();
});
$(“#隐藏面板”).fadeOut();
});  
//启动“添加到购物车”按钮
$('.shopme p')。单击(函数(){
var pid=$(this.attr('rel');
$('body')。前缀(“”);
var shadow=$('#'+pid+'#u shadow');
shadow.width($(this.parent().css('width')).height($(this.parent().css('height')).css('top',$(this.parent().offset().top.).css('left',$(this.parent().offset().left)).css('opacity',0.5).show();
css('position','absolute');
阴影.动画({
宽度:$('#btntarget')。innerWidth(),
高度:$('#btntarget')。内部高度(),
顶部:$('#btntarget').offset().top,
左:$('#btntarget').offset().left
}, { 
持续时间:2000年
} )
.animate({
不透明度:0
},
{ 
持续时间:700,
完成:函数(){
shadow.remove();
}
});
var option=$('#'+pid+'.wooptions').val();
var formData='pid='+pid+'&option='+option;
$.ajax({
键入:“POST”,
url:“/wooo/cart.php”,
数据:formData,
成功:函数(html){
$('#panelcontent').html(html);
}
});
}); 
$('.removietem').live('click',function(){/.live在这里使用
rid=$(this.attr('id');
rop=$(this.attr('rel');
var remData='remove='+rid+'&rop='+rop;
$.ajax({
键入:“POST”,
url:“/wooo/cart.php”,
数据:remData,
成功:函数(html){
$('#panelcontent').html(html);
//警报(“thx”);
}
});
});
}); // 文件
函数签出(){
jQuery.ajax({
url:“/wooo/cart.php”,
类型:“POST”,
数据:“destroysession=true”,
成功:函数(数据、文本状态、jqXHR){
如果(数据){
window.location.href=jQuery('a.checkout').attr(“data href”);
}否则{
log(“没有数据!”)
}
},
错误:函数(jqXHR、textStatus、errorshown){
log(“AJAX错误:+errorshown”)
}
});
}
/**替换******/
jQuery.fn.bloooming_shop=函数(){
这个。每个(函数(){
var elem=$(本);
var cl='bt1';
var id=$(this.html();
var opt=$(this.attr('options');
var text=$(this.attr('text');
var price=$(this.attr('price');
//警报(价格);
如果(文本==未定义){
text='添加到购物车';
}
如果(opt='true'&&price!='true'){
cl=‘bt3’;
}
如果(价格='true'&&opt='true'){
cl=‘bt4’;
}
如果(价格='true'&&opt!='true'){
cl=‘bt2’;
}
元素移除类(“wooo”);
元素addClass(“shopme”);
元素添加类(cl);
元素属性('id','pid'+id);
html(“

“+text+”

”); //获取产品数据 if(price==“true”| | opt==“true”){ $.ajax({ 键入:“GET”, url:'/wooo/functions.php?mode=p_data&id='+id+'&opt='+opt+'&price='+price, 成功:函数(html){ 元素附加(html); if(jQuery().sSelect){ elem.children('.wooptions').sSelect(); } //变价 $('.wooptions').change(函数(){ var selid=$(this.attr('id'); var rel=$('#'+selid+'选项:selected')。attr('rel'); 如果(rel!=未定义){ $(this.parent().children('.woooprice').html(rel); } }); } }); } }); 返回false; };
我如何保持这个插件的活力,即使是在ajax'ed-in#容器中?我真的只需要“添加到购物车”按钮(shopme p)在所说的容器分区。谢谢

.live("click", function(){

不要只是点击。

首先,把
$.live()
从你的脑海中抹去;它的效率非常低,而且“早就被弃用了”<代码>$.delegate()我相信也是。如果需要挂接el的事件,请使用
$.on()
.live("click", function(){