Skip to content

Selectize create to show / hide inputs #1422

@Hydro8

Description

@Hydro8

Hi

I want to use selectize to show inputs if new option is create or to hide inputs if default option is select.

Here my html code for my selectize :

<select id="select-type" name="type" class="form-control" placeholder="Sélectionnez ou ajoutez un type de fraction" required> <option value="">Sans</option> @foreach($types as $type) <option value="{{$type['nom']}}">{{$type['nom']}}</option> @endforeach </select>

And my js code :
$select_type = $('#select-type').selectize({ highlight: false, readonly: true, create: true, persist: false, render: { option_create: function(data, escape) { return '<div class="create">Ajouter le bâtiment <strong>' + escape(data.input) + '</strong>&hellip;</div>'; } }, onOptionAdd: function(value) { $('.new_fraction').show(); } });

First problem : persist option doesn't seem to work. When I create an option, then select back a default option, my created option is selectable.

Second problem : when I add an option, inputs are shown. But how to know that I select back a default options ?

Thank for your help !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions