我正在尝试在创建新产品时设置 jquery 链式选择
- 性别
- 类别
- 子类别
性别和类别是链接的,减去不出现的子类别!
请问有人可以给点光吗?谢谢
$(document).ready(function () {
var $gender, $category;
$gender = $('input[id^="product_gender_id"]');
$category = $('#product_category_id');
//radio only can response to 'click' event, rather than select event you wrote before.
$gender.click(function () {
var gender = $('input[id^="product_gender_id"]:checked').val();
if (gender == 1);
else if (gender == 2);
jQuery.get('/products/update_category_select/' + gender, function(data){
$("#productCategories").html(data);
})
});
$category.change(function() {
// make a POST call and replace the content
var category = $('select#product_category_id :selected').val();
if(category == "") category="0";
jQuery.get('/products/update_subcategory_select/' + category, function(data){
$("#productSubcategories").html(data);
})
return false;
});
});