新手问题 有人研究过 select2 吗?selecting 事件里的 e.object 获取不了父对象 select

stephen · April 18, 2014 · 3296 hits

我使用 select2 来实现一个下拉功能,使用了 basic! html:

select.select_food#select_food_3
      option value="1"

javascript:

$(".select_food").select2().on("select2-selecting", function(e) {
      alert($(e.object).parent().attr("id"));
      $("#input_food_3").val(e.val);
      alert($("#input_food_3").val());
 });

他的文档说 e 有两个属性,分别为 val 和 object

val
The id of the highlighted choice object.
object
The choice object about to be selected.

但是我通过

$(e.object).parent().attr("id")

获得为空, 正确应该怎样获取

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.