English 中文(简体)
从ajax- chosesen 插件中获取选中选项
原标题:Get selected options from from ajax-chosen plugin

我正在想办法从“https://github.com/meltingice/ajax-chosen' rel=“nofollow”>ajax-Chosen 插件中找到选择选项。

这是我的 html :

<select multiple= multiple  class= chzn-select  data-placeholder= users >
  <option value= 0  selected>username1</option>
  <option value= 1  selected>username2</option>
</select>

这是联署材料的一部分:

$(".chzn-select").ajaxChosen({
  method:  GET ,
  url:  users.php ,
  dataType:  json ,
  minTermLength: 3,
  afterTypeDelay: 300
}, function (data) {
  var terms = {};

  $.each(data, function (i, val) {
     terms[i] = val;
  });

  return terms;
});

这一切都很好。 但当我删除一个选项“ 用户名2 ” 时, 选中的字段不会更新。 所以当我想从列表中获取所有选中的用户时, 我就会错误地获得列表 - 在这种情况下, 我总是得到两个数值, 即使其中之一被从列表中删除 。

我也曾尝试在毫无运气的情况下触发最新消息:

$(".chzn-select").trigger("liszt:updated");

是否有人建议从选中列表中获取真实值?

最佳回答

藉由stof ,

Instead of $(".chosen-select option").each(); I did this: $(".chosen-select).val();

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签