久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

jQuery Chosen - 更新選擇列表而不丟失選擇

jQuery Chosen - update select list without losing selections(jQuery Chosen - 更新選擇列表而不丟失選擇)
本文介紹了jQuery Chosen - 更新選擇列表而不丟失選擇的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試使用 jQuery 插件Chosen"

I'm trying to use jQuery plugin "Chosen"

(http://harvesthq.github.com/chosen/ 和 https://github.com/harvesthq/chosen)

在我的項目中.

我想要實現的是基于用戶選擇的更新列表(ajax 調用(tree based structure))

What I'm trying to achieve is update list basing on user selection (ajax call (tree based structure))

這不是更大的問題,因為我可以使用 .chosen().change(function()) 并刪除所有未使用的選擇項,然后 .append 新的.

This is no bigger problem, because i can use .chosen().change(function()) and remove all unused select items and then .append new ones.

然后我可以使用 .trigger("liszt:updated") 更新列表,但不幸的是所有選擇都被刪除了..

Then I can use .trigger("liszt:updated") to update list, but unfortunately all selections are deleted..

有誰知道如何在不丟失所選數據的情況下更新所選列表?

Does anyone know a way how to update chosen list without loosing selected data?

理論上,我可以手動刪除所有選擇的生成

  • 元素,然后用新元素填充,但是獲取 SELECT "value" 數據時會出現問題.

    In theory I can manually remove all chosen generated

  • elements and then populate with new ones, but then is a problem with getting SELECT "value" data.

    推薦答案

    如果您保存選定的項目,這應該相當簡單.例如:

    This should be fairly simply if you save the items selected. For example:

    <select data-placeholder="Choose a country..." style="width:350px;" multiple="true"  class="chosen-select">
    $(".chosen-select").chosen();
    

    現在,在更新所選項目之前,請確保您保存所選項目,如下所示:

    Now, before updating the chosen, make sure you save the items selected like this:

    var chosenSelectedItems = $(".chosen-select").val(); // this gets you the select value data
    // Update the select items
    $('.chosen-select').trigger('liszt:updated');
    $(".chosen-select").val(chosenSelectedItems);
    

    這應該可以在更改之前重置原始值.

    This should be able to reset the original values before the change.

    這篇關于jQuery Chosen - 更新選擇列表而不丟失選擇的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

    【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!
  • 相關文檔推薦

    jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
    How to do following mask input problem?(如何做以下掩碼輸入問題?)
    Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
    how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
    stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
    jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
    主站蜘蛛池模板: 视频一区二区在线 | 毛片高清 | 欧美午夜精品久久久久久浪潮 | 欧美视频xxx | www.久久精品视频 | 午夜精品视频在线观看 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 日本在线中文 | 亚洲三区在线 | 日韩在线小视频 | 国产激情网 | 日韩欧美一区二区三区在线播放 | 午夜精品视频在线观看 | 免费欧美 | 久久久精品视频免费看 | 99久久婷婷国产综合精品电影 | 久久久久国产精品一区二区 | 国产精品欧美一区二区三区 | 欧美一区二区综合 | 精品国产久 | 精品久久久久久久久久久 | 一区在线视频 | 欧美一区二区小视频 | 男女下面一进一出网站 | 国产精品一区一区 | 色婷婷av一区二区三区软件 | 欧美色欧美亚洲另类七区 | 欧美一区二区三区在线播放 | 播放一级黄色片 | 欧美天堂一区 | 日本精品一区二区 | 成人在线看片 | 久久免费精品视频 | 日韩中文一区二区三区 | 亚洲欧美在线视频 | 色黄网站 | 精品产国自在拍 | 国产电影一区二区在线观看 | 中文一区二区 | 97精品超碰一区二区三区 | 国产精品免费在线 |