jQuery多选重新加载 [英] jquery multiselect reload

查看:109
本文介绍了jQuery多选重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 JQuery UI Multiselect 中添加或删除选项?我正在页面加载时初始化多选,我需要删除现有值并根据其他选择添加新值.我正在使用以下方法在页面加载时初始化多选:

How can I add or remove options in JQuery UI Multiselect ? I am initializing the multiselect on page load and I need to remove existing values and add new values based on another selection. I am initializing the multiselect on page load using:

$("#multipleselectboxId").multiselect();

在那之后,我使用jQuery append()remove()方法将值添加到多重下拉列表中,这些方法在原始下拉列表中工作正常,但在multiselect中没有得到体现.

After that, I am adding values to the multiple drop down using jQuery append() and remove() methods which are working fine with original dropdown but in the multiselect are not getting reflected.

任何人都可以帮忙吗?

推荐答案

我找到了解决方案,首先销毁了多重选择并重新初始化它,谢谢@ Brandon Joyce,

I found the solution for this, first destroy the multiselect and reInitialize it, Thanks for @ Brandon Joyce,

解决方案是

$("#multipleselectboxId").append(toAppend);
$("#multipleselectboxId").remove(toRemove);

$("#multipleselectboxId").multiselect('destroy');
$("#multipleselectboxId").multiselect();

这篇关于jQuery多选重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆