-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
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>…</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 !