1

ivaynberg's select2 has this great feature query ( a property of the options object that gets passed to the call to select2({}))

The trouble I'm having is using this feature with angular-ui's ui-select2 implementation.

I wanna do something like:

$scope.select2Options = {
  query: function(options) {
    $http({
      method: 'GET'
      url: '/some/url'
      params: options.term
    })

    .success( function(result, status, headers, config) {
      // do some parsing here to get results looking right
      options.callback({result: result});
    });
}

like..I've not been able to get something like this working - query never gets called - and when I do as suggested on ivaynberg's github page and change the <select> to an <input type="hidden" ... /> I see nothing.

Kevin Friedheim
  • 394
  • 3
  • 15

1 Answers1

1

It's a bug of ui-select2 which I made a pull request to address it but it's still pending. You could refer it here: Ajax multiple bug fix for ui-select2

The fix is quite simple, you just need to add those lines inside the condition angular.isString(viewValue) in controller.$render

if (opts.ajax) {
  return;
}
VinhBS
  • 677
  • 8
  • 17
  • I'll give this a try and report back with results - but to be clear - does this enable ajax only? or after this change, would query also work? – Kevin Friedheim Jun 18 '14 at 19:37
  • @KevinFriedheim I haven't tried with `query` option yet, but I think you could change the fix to `opts.ajax || opts.query`. Regards. – VinhBS Jun 19 '14 at 20:18