0

Folks,

I have a problem with jquery choosen plugin.

I have 2 lists of items, list_of_all_items (it's list of all items in all cases) and list_of_items_in_case (it's list of items in specify case). Items from list list_of_items_in_case are also included in list list_of_all_items And I need to make 3 things in one form:

  1. Select all items from list_of_items_in_case automatically (all items from this list should be selected),
  2. Posibiliteis to select every single item from list list_of_all_items,
  3. Posibilities to add new item by de customer.

I found this plugin here https://harvesthq.github.io/chosen/. And I created only this:

{% block head %}

<script type="text/javascript" src="{% static '/plugins/chosen/chosen.jquery.min.js' %}"></script>
<link rel="stylesheet" href="{% static '/plugins/chosen/chosen.css' %}">

<style>
items p{
      font-size: 1em;
      font-weight: bold;
      padding: 1em;
      margin: 0;
      display: table;
</style>
<script type="text/javascript">
    function onTagChange()
    {
      $( "#form_tags" ).submit();
    }
    $(document).ready(function () {
        $(".chosen-select").chosen();
    });
</script>
{% endblock %}
{% block nav %}{% endblock %}
{% block content %}
<form id="items" method="post">

   {% for item in list_of_items_in_case %}
<div class="box items">
    <div class="items">
        <p><font color="greenyellow"><b>Items: </b></font>{{ list_of_items_in_case }}</p>

        <select id="items" name="item" multiple class="chosen-select" tabindex="2" for="items">
    {% for item in list_of_items_in_case %}
    <option value="{{item}}">{{item}}</option>
    {% endfor %}
    </select>

</div>
<hr /><br>
<hl></hl>
{% endfor %}
</form>

And only thing which it's able to make is preprare a form where I can select items from list_of_items_in_case and I've no idea how to do the rest properly.

Maybe I expect too much from this plugin and should I find another?

BR, Damian

Damian Silkowski
  • 127
  • 2
  • 13
  • Problem is not clear at all. You only show one list of options. Provide a [mcve] – charlietfl Nov 27 '17 at 20:04
  • I hope now is better :) – Damian Silkowski Nov 27 '17 at 21:31
  • chosen is not fulfill your requirement. user are not allow to input another value. you still can hack this like https://stackoverflow.com/questions/7385246/allow-new-values-with-chosen-js-multiple-select . but in my experience using chosen, selectize, select2, jquery-ui autocomplete. i this case, i would recommended you to migrate to selectize because selectize fulfi;l all your requirements look this https://selectize.github.io/selectize.js/ , find `Single Item Select` then try to add new value – plonknimbuzz Nov 28 '17 at 08:07

0 Answers0