Created
September 20, 2017 22:17
-
-
Save jorgeandrescastro/8d99081f48922ca7d81b872f08f68135 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $lookup = $('.js-lookup'); | |
| $lookup.select2({ | |
| ajax: { | |
| dataType: 'json', | |
| delay: 250, | |
| data: function(params) { | |
| return { | |
| search: params.term | |
| } | |
| }, | |
| processResults: function(data) { | |
| return { | |
| results: $.map(data.data, function(children, group) { | |
| return { | |
| text: group, children: $.map(children, function (text, value) { | |
| return { id: value, text: text } | |
| }) | |
| } | |
| }) | |
| // results: $.map(data.data, function(text, value) { | |
| // return { id: value, text: text } | |
| // }) | |
| }; | |
| }, | |
| cache: true | |
| }, | |
| width: '100%', | |
| minimumInputLength: 2, | |
| theme: 'bootstrap', | |
| allowClear: true | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment