how to show results in semantic-ui api

烂漫一生 提交于 2019-12-08 15:15:31
NobbyNobbs

when it sends the request and receives the data, all data stores in browser session storage. i set 'saveRemoteData' to false but after each request i checked the storage and i found the new record on that.

Probably it's the API's bug. I've had the same issue, and I couldn't find solving in internet. So I wrote my own kludge.

HTML:

<div id="my_dropdown" class="ui multiple search selection dropdown select-city">
    <input type="hidden" name="city"> <i class="dropdown icon"></i>
    <div class="default text">Select city</div>
    <div class="menu"></div>
</div>

and JS inside dropdown({}):

beforeSend: function(settings) {
    /**
     * minCharacters option doesn't work form me with dropdown,
     * so I'm checking length manually and clear the search result in DOM
     * and reject request if search string is too short
     */
     if ($("#my_dropdown").find("input.search").val().length < 3) {
         $("#my_dropdown").find(".menu.transition.visible").html("");
         return false;
     }
     /**
      * here I'm manually clearing the cache in localStorage
      */
     if (typeof(Storage) !== "undefined") {
         var sStorage = window.sessionStorage;
         //console.log(sStorage.getItem("/my/request/url/"));
         sStorage.removeItem("/my/request/url/");
     }
     /**
      * some standard actions
     */
     settings.data.str = $("#my_dropdown").find("input.search").val();
     console.log(settings.data);
     return settings;
}

Looks a bit ugly, but works for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!