根据其自己的 click:event 从多选容器中获取所有选定的 val() ?
根据以下 multiselect 我需要获取所选的选定值来自一页上的许多多重下拉菜单。我有一个通用事件处理程序设置,如果在页面上的任何多选上单击一个选择,则会触发一个公共事件。两个问题:
1)我如何知道事件来自哪个 muliselect (#Name)? 2)如果事件来自同一个容器,如何从多选单击函数中获取 .val() ?
// generic event for all multiselect
$("select").multiselect({
click: function (event, ui) {
// 1 - What multiselect container?
// 2- Get the list of selected values
var vals = $('#CNames').val(); // This doesn't work if the event was fired from #CNames..null.
var vals = $('#CAreas').val(); // This works if the event came from #CNames.
Per the following multiselect I need to grab the selected values that are selected from many multidropdowns on one page. I have a generic event handler setup where if a selection is clicked on any of the multiselect on the page it fires a common event. Two problems/questions:
1) How can I tell what muliselect (#Name) the event came from?
2) How can I grab the .val()'s from the multiselect click function if the event is from the same container?
// generic event for all multiselect
$("select").multiselect({
click: function (event, ui) {
// 1 - What multiselect container?
// 2- Get the list of selected values
var vals = $('#CNames').val(); // This doesn't work if the event was fired from #CNames..null.
var vals = $('#CAreas').val(); // This works if the event came from #CNames.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能可以获得单击的选择的 id
以及所有选择的值
或当前选择的值
You can probably get the id of the select that was clicked with
and the values of all the selects with
or the current select with
aliz 的代码应该可以工作。尝试按照文档显示的方式绑定它们:
The code from aliz should work. Try binding them all the way the documentation shows: