//点击保存 将选中的乐器传入
$(".YQQH_top input").click(function(){
var checked=$(".YQQH-title i").hasClass("iactive");
if(checked==true){
var uid={$uid};
var avtive=$(".iactive").siblings(".p");
var str="";
for(var i=0;i<avtive.length;i++){
var active=avtive[i].dataset.id;
str +=active+","
}
$.ajax({
url:"{php echo $this->createMobileUrl('index', array('op' => 'want'))}",
dataType:'json',
type:'POST',
data:{want:str},
success:function(msg){
if(msg.code==0){
mui.toast('保存成功', {
duration: 'long',
type: 'div'
});
$(".YQQH").hide();
}else{
mui.toast('保存失败', {
duration: 'long',
type: 'div'
});
$(".YQQH").hide();
}
}
});
}else if(checked==false){
mui.toast('请选择乐器', {
duration: 'long',
type: 'div'
});
}
});
//点击切换乐器
mui("body").on("tap", "#qiehuanYueqi", function() {
$(".YQQH").show();
var music='{$musical}'; //*
var str=eval("("+music+")"); //这个eval可以让"['1','1']" 转为数组
for(var i = 0;i<str.length;i++){
$(".p[data-id]").each(function () {
var a = $(this).attr("data-id");
if(a === str[i]){
$(this).siblings('i').addClass('iactive');
}
});
}
return false;
});
网友评论