diff --git a/Readme.md b/Readme.md
index 6c043df..8e6b3df 100644
--- a/Readme.md
+++ b/Readme.md
@@ -9,6 +9,7 @@ Select2 est actif dans l’espace privé pour tous les select ayant la classe CS
La configuration (Menu : Squelettes > Select2) permet de compléter les sélecteurs utilisés.
Il est possible d’activer Select2 sur l’espace public depuis cette configuration.
+**Important:** L’identifiant (l’attribut `id`) de la balise `select` doit être unique sur la page ; Select2 ne peut s’activer qu’une fois par identifiant (le dernier appelé).
## Compléter la configuration par défaut
diff --git a/javascript/spip_select2.js b/javascript/spip_select2.js
index e69de29..a301d91 100644
--- a/javascript/spip_select2.js
+++ b/javascript/spip_select2.js
@@ -0,0 +1,22 @@
+;jQuery(function($){
+ spip_select2 = function() {
+ jQuery('select.select2').select2();
+ if (typeof select2 !== 'undefined') {
+ if ((typeof select2.selector !== 'undefined') && !!select2.selector) {
+ jQuery(select2.selector).select2();
+ }
+ }
+ jQuery('select.select2[data-sort-alpha=true]').select2({
+ /*'sorter': data => data.sort((a, b) => a.text.localeCompare(b.text))*/
+ sorter: function (data) {
+ return data.sort(function (a, b) {
+ return a.text.localeCompare(b.text);
+ })
+ }
+ });
+ }
+
+ spip_select2();
+ onAjaxLoad(spip_select2);
+});
+
diff --git a/lang/select2_fr.php b/lang/select2_fr.php
index fb51fc9..939fc47 100644
--- a/lang/select2_fr.php
+++ b/lang/select2_fr.php
@@ -13,7 +13,7 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
// C
'champ_active_label' => 'Activer "Select2" dans le site public',
'champ_selecteur_label' => 'Sélecteur',
- 'champ_selecteur_explication' => 'Indiquez la cible des éléments qui déclencheront Select2. (Expression CSS ou étendue jQuery)',
+ 'champ_selecteur_explication' => 'Indiquez la cible des éléments qui déclencheront Select2, en plus de la classe CSS .select2
. (Expression CSS ou étendue jQuery)',
// T
'titre_page_configurer_select2' => 'Configurer Select2',
diff --git a/select2_pipelines.php b/select2_pipelines.php
index 63f5676..60b48c8 100644
--- a/select2_pipelines.php
+++ b/select2_pipelines.php
@@ -49,6 +49,10 @@ function select2_jquery_plugins($flux) {
*/
function select2_header_prive($flux) {
include_spip('inc/config');
+ $flux .= ''."\n";
return $flux;
}
@@ -95,7 +99,10 @@ function select2_insert_head($flux) {
include_spip('inc/config');
$config = lire_config('select2', array());
if (isset($config['active']) and $config['active']=='oui') {
-
+ $flux .= ''."\n";
}
return $flux;
}