From b85cf14af8adcde3d4a142ad9c39608b8b0f075e Mon Sep 17 00:00:00 2001 From: Massimo Menichinelli Date: Wed, 28 Mar 2018 21:12:47 +0200 Subject: [PATCH 1/2] Add full version of Select2 for #34 --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index 648b396..5ab7d9b 100644 --- a/package.js +++ b/package.js @@ -10,7 +10,7 @@ Package.on_use(function(api) { api.use("jquery", "client"); api.add_files([ - "lib/select2/dist/js/select2.js" + "lib/select2/dist/js/select2.full.min.js" ], "client", { bare: true }); api.add_files([ From 58bea9b647462452728947dffc29849071ebeaa5 Mon Sep 17 00:00:00 2001 From: Massimo Menichinelli Date: Fri, 30 Mar 2018 20:51:24 +0200 Subject: [PATCH 2/2] Complete minimal example in README.md for #28 --- README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2ec6ab6..c5e3041 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ meteor add natestrauser:select2 ## How to use -Add a specific class in your template for the select element you want to apply Select2 to: +Add a specific class in your template for the select element you want to apply Select2 to (and read the value of _data-id_): ```html - + + ``` @@ -34,4 +34,22 @@ Template.MyTemplate.onRendered(function() { }); ``` +Add a function for the selection event: + +```javascript +'change select': function(event, template) { + var id = $('#select2-example option:selected').data('id'); + } +``` + +Or for any other events: + +```javascript +'click #save-button': function(event, template) { + var id = $('#select2-example option:selected').data('id'); + } +``` + + + See also the [Select2 documentation](https://select2.org/). \ No newline at end of file