【发布时间】:2014-02-04 16:10:29
【问题描述】:
我有两个下拉列表,第一个下拉列表的选择正确填充第二个。我已经使用 ajax-php 成功实现了它。
现在我正在尝试使用selectize.js,应用于select(第一个下拉列表)中的第一个,它可以正常工作,但第二个下拉列表没有正确填充。我已经阅读了文档(这不是我读过的最好的),我认为默认情况下 selectize.js 无法处理元数据。
但是有一个addOption() 和一个addItem() 方法是我应该实现的。我的问题是我找不到解析ajax-php 给出的结果的方法(并存储为@987654325 @ 在第二个下拉列表中)并正确使用它们...
PHP 代码
echo "<select name='universities' id='universities' ></select>"; //Here is where the second dropdown is populated properly
JQuery 代码-更新第二个下拉菜单
//Successfully the second dropdown is populated before
$("#universities").selectize();
//If i change the first dropdown option now,the second dropdown remains the same
//if i comment $("#universities").selectize(); line everything works fine.
有什么想法吗?
【问题讨论】:
标签: jquery selectize.js