更新后“刷新" jQuery UI选择菜单 [英] 'refresh' jquery UI selectmenu after update

查看:99
本文介绍了更新后“刷新" jQuery UI选择菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个get请求,该请求获取一堆类别信息以填充<select>.我正在使用jQuery UI Selectmenu设置我的选择的样式.

I have an get request which fetches a bunch of category information to populate a <select>. I'm using jQuery UI Selectmenu to style my select.

所以我的jQuery看起来像这样:

So my jQuery looks a little like this:

//Initalise the selectmenu
$("select").selectmenu({ style: 'dropdown' });

$.get("http://localhost/somedata?cat=2", function (data) {
    $.each(data, function (index, itemData) {
        $("<option value='" + itemData.Id + "'>" + itemData.Name + "</option>").appendTo("#selectList");
    });
});

但是,这会填充<select>,但不会更新jQuery UI选择菜单.有什么想法我需要做些什么才能使选择菜单重新绘制",以便新值出现在选择菜单中?

However this populates the <select> but does not update the jQuery UI selectmenu. Any ideas what I need to do to get the selectmenu to be 're-drawn' so the new values appear in the selectmenu?

推荐答案

您可以使用

更新:不幸的是,已记录了refresh函数,但似乎尚未实现.另一个选择是销毁小部件并重新创建它:

Update: Unfortunately, the refresh function is documented but does not seem to be implemented yet. Another option is to destroy the widget and recreate it:

$("select").selectmenu("destroy").selectmenu({ style: "dropdown" });

这篇关于更新后“刷新" jQuery UI选择菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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