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 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([