From c82ad36335fe94f72fa3ab32a6719e9a94f8e80b Mon Sep 17 00:00:00 2001 From: Bradley Stafford Date: Fri, 23 Sep 2016 21:53:51 -0700 Subject: [PATCH] update Select2 integration example and explanation (#1028) * update Select2 integration example and explanation * integrate feedback per PR * oops. integrate the feedback that I missed initially * make docs great again --- docs/integration.md | 173 +++++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 91 deletions(-) diff --git a/docs/integration.md b/docs/integration.md index 918b6c08..36950227 100644 --- a/docs/integration.md +++ b/docs/integration.md @@ -7,110 +7,102 @@ It's recommended that you encapsulate integration code in a component or a helpe The example below shows a simple component that integrates with the [select2 library](http://ivaynberg.github.io/select2/). ```javascript -var Select2 = { - // Returns a select box - view: function(ctrl, attrs) { - var selectedId = attrs.value().id; - //Create a Select2 progrssively enhanced SELECT element - return m("select", {config: Select2.config(attrs)}, [ - attrs.data.map(function(item) { - var args = {value: item.id}; - // Set selected option - if(item.id == selectedId) { - args.selected = "selected"; - } - return m("option", args, item.name); - }) - ]); - }, - /** - Select2 config factory. The params in this doc refer to properties of the `ctrl` argument - @param {Object} data - the data with which to populate the