jQuery Chosen with cascading选择不起作用

时间:2014-03-07 19:54:51

标签: javascript jquery select jquery-chosen cascading

我有3个从数据库中填充的选择框。然后我使用这个javascript使它们级联(取决于父选择框中的选择):

function cascadeSelect(parent, child){
var childOptions = child.find('option:not(.static)');
child.data('options',childOptions);

parent.change(function(){
    var parentValue = (this.value).replace(" ", "_");
    childOptions.remove();
    child
        .append(child.data('options').filter('.sub_' + parentValue))
        .change();
})

childOptions.not('.static, .sub_' + parent.val()).remove();
}

这适用于原生选择框。问题是,当我使用jQuery Chosen时,无论在前一个框(父级)中选择了什么,都会在每个选择框中返回所有选项。

在此处链接到构建页面:http://site4.i-ocom.com/ 三个选择框ID是:#Make_395,#Model_395,#Trim_395 我已经阅读了所选的文档并尝试过:

 $("#Make_395").chosen().change(function(){
 $("#Model_395").trigger('chosen:updated');
 });

 $("#Model_395").chosen().change(function(){
 $("#Trim_395").trigger('chosen:updated');
 });

以及其他一些不起作用的东西。我很难受到任何帮助。

1 个答案:

答案 0 :(得分:1)

实际上你有一个非常旧版本的选择插件(0.14,而github上的最新版本是1.1),所以手册中的内容可能对你不起作用。更新您的js,然后重试。

相关问题