Multiple select error using form tab navigation.
Hello,
When I press the tab key of the keyboard to navigate through the form fields and get to the multiple select input, it crashes and stops work if I press the key down arrow to select an option, and I can't select any options any more even with the mouse.
Only refreshing the page makes it work again.
Firebug console shows this error.
Error: scope.$activeIndex.indexOf is not a function
SelectFactory/$select.$isActive@http://localhost:65187/Scripts/angular-strap.js:2993:20
SelectFactory/scope.$isActive@http://localhost:65187/Scripts/angular-strap.js:2912:18
Parser.prototype.functionCall/<@http://localhost:65187/Scripts/angular.js:10836:15
OPERATORS["&&"]@http://localhost:65187/Scripts/angular.js:10188:62
Parser.prototype.binaryFn/<@http://localhost:65187/Scripts/angular.js:10590:14
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost:65187/Scripts/angular.js:12504:34
SelectFactory/$select.$onKeyDown@http://localhost:65187/Scripts/angular-strap.js:3034:11
jQuery.event.dispatch@http://localhost:65187/Scripts/jquery-1.10.2.js:5108:15
jQuery.event.add/elemData.handle@http://localhost:65187/Scripts/jquery-1.10.2.js:4780:6
TypeError: scope.$activeIndex.indexOf is not a function
SelectFactory/$select.$isActive()angular-strap.js (line 2993)
SelectFactory/scope.$isActive()angular-strap.js (line 2912)
Parser.prototype.functionCall/<()angular.js (line 10836)
Parser.prototype.object/<()angular.js (line 10899)
$RootScopeProvider/this.$get</Scope.prototype.$digest()angular.js (line 12504)
SelectFactory/$select.$onKeyDown()angular-strap.js (line 3034)
jQuery.event.dispatch()jquery-1.10.2.js (line 5108)
jQuery.event.add/elemData.handle()jquery-1.10.2.js (line 4780)
return scope.$activeIndex.indexOf(index) !== -1;
Anyone have idea how to solve this?
Thank you!
What versions of AngularJS/AngularStrap are you using? Can you post a sample?
Angular Strap Version @version v2.1.6 - 2015-01-11
Angular JS Version @license AngularJS v1.2.23
Here's a code sample
Here's the controller
(function ($) {
'use strict';
app.controller('myController', ['$scope', '$q', function ($scope, $q) {
$scope.myContracts = [
{
"id":1,
"code":"CNT01",
"name":"Contract 01",
"startedIn":"2014-07-29T14:01:22"
},
{
"id":2,
"code":"CNT02",
"name":"Contract 02",
"startedIn":"2014-07-29T14:02:05"
},
{
"id":3,
"code":"CNT03",
"name":"Contract 03",
"startedIn":"2014-07-29T14:02:05"
},
{
"id":4,
"code":"CNT04",
"name":"Contract 04",
"startedIn":"2014-10-03T09:00:00"
}
];
}]);
}(jQuery));
Here's the form item
<button type="button" name="contracts" id="contracts" class="btn btn-default btn-contracts" ng-model="myModel.contracts" data-html="1" validate-select data-multiple="1" data-animation="am-flip-x" placeholder="Select a contract..." max-length="2" max-length-html="selected" ng-required="true" template="contractSelect.html" ng-options="contract.id as contract.name for contract in myContracts" bs-select>
<span class="caret"></span>
</button>
<div ng-show="formSubmitted" class="error-form-validation">
<div ng-show="myForm.contracts.$error.required">Select at least one contract</div>
</div>
Here's the template
<script type="text/ng-template" id="contractSelect.html">
<ul tabindex="0" class="select dropdown-menu" ng-show="$isVisible()" role="select">
<li role="presentation" ng-repeat="match in $matches" ng-class="{active: $isActive($index)}">
<a style="cursor: default;" role="menuitem" tabindex="0" ng-click="$select($index, $event)">
<i class="{{$iconCheckmark}} pull-right" ng-if="$isMultiple && $isActive($index)"></i>
<span>{{match.label}}</span>
</a>
</li>
</ul>
</script>
There was a small fix for this in https://github.com/mgcrea/angular-strap/commit/516b67bbbfb719ff9d4876cfa69d7efe158cd88b, so it should be ok in latest version of angular-strap
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.