diff --git a/src/bootstrap/no-choice.tpl.html b/src/bootstrap/no-choice.tpl.html new file mode 100644 index 000000000..fdd1391f7 --- /dev/null +++ b/src/bootstrap/no-choice.tpl.html @@ -0,0 +1,6 @@ +
diff --git a/src/bootstrap/select.tpl.html b/src/bootstrap/select.tpl.html index 880396a38..a51cbdef4 100644 --- a/src/bootstrap/select.tpl.html +++ b/src/bootstrap/select.tpl.html @@ -10,4 +10,5 @@ ng-model="$select.search" ng-show="$select.searchEnabled && $select.open"> + diff --git a/src/common.css b/src/common.css index e1026d4a1..59450790a 100644 --- a/src/common.css +++ b/src/common.css @@ -148,7 +148,7 @@ body > .select2-container.open { } /* See Scrollable Menu with Bootstrap 3 http://stackoverflow.com/questions/19227496 */ -.ui-select-bootstrap > .ui-select-choices { +.ui-select-bootstrap > .ui-select-choices ,.ui-select-bootstrap > .ui-select-no-choice { width: 100%; height: auto; max-height: 200px; diff --git a/src/uiSelectDirective.js b/src/uiSelectDirective.js index fc6cc4138..ec8a33e1d 100644 --- a/src/uiSelectDirective.js +++ b/src/uiSelectDirective.js @@ -186,6 +186,13 @@ uis.directive('uiSelect', throw uiSelectMinErr('transcluded', "Expected 1 .ui-select-choices but got '{0}'.", transcludedChoices.length); } element.querySelectorAll('.ui-select-choices').replaceWith(transcludedChoices); + + var transcludedNoChoice = transcluded.querySelectorAll('.ui-select-no-choice'); + transcludedNoChoice.removeAttr('ui-select-no-choice'); //To avoid loop in case directive as attr + transcludedNoChoice.removeAttr('data-ui-select-no-choice'); // Properly handle HTML5 data-attributes + if (transcludedNoChoice.length == 1) { + element.querySelectorAll('.ui-select-no-choice').replaceWith(transcludedNoChoice); + } }); // Support for appending the select field to the body when its open diff --git a/src/uiSelectNoChoiceDirective.js b/src/uiSelectNoChoiceDirective.js new file mode 100644 index 000000000..a6f47ec7e --- /dev/null +++ b/src/uiSelectNoChoiceDirective.js @@ -0,0 +1,14 @@ +uis.directive('uiSelectNoChoice', + ['uiSelectConfig', function (uiSelectConfig) { + return { + restrict: 'EA', + require: '^uiSelect', + replace: true, + transclude: true, + templateUrl: function (tElement) { + // Gets theme attribute from parent (ui-select) + var theme = tElement.parent().attr('theme') || uiSelectConfig.theme; + return theme + '/no-choice.tpl.html'; + } + }; + }]); \ No newline at end of file