UI Select Multiselect
How do I make an ui select multiselect?
UISelect already supports multi-select, but I needed something a bit different. Here's what I came up with.. What is a ui select multiselect? How do you make a ui select multiselect? This script and codes were developed by Chris Hanson on 01 October 2022, Saturday.
UI Select Multiselect - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>UI Select Multiselect</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css'>
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.11.2/select.min.css'>
<link rel='stylesheet prefetch' href='https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css'>
<link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ .container { width: 500px; margin: 30px auto;
}
.user-select { width: 60%; float: left;
}
.result { padding-left: 10px; float: left;
}
.mark-all { font-size: 12px; margin: 5px 0;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="container" ng-app="App" ng-controller="AppCtrl as app"> <div class="user-select"> <ui-select ng-model="app.userSearch" theme="bootstrap" close-on-select="false" on-select="app.onUserSelect($select.selected)"> <ui-select-match ng-attr-placeholder="{{ app.getPlaceholder() }}"> {{ app.getPlaceholder() }} </ui-select-match> <ui-select-choices repeat="user in app.users | filter:$select.search"> <div><i ng-show="user.$isSelected" class="fa fa-check"></i> {{ user.name }}</div> </ui-select-choices> </ui-select> <div class="mark-all"> <a href ng-click="app.markAllAs(true)">Select All</a> | <a href ng-click="app.markAllAs(false)">Deselect All</a> </div> </div> <div class="result"> <pre>Selected user IDs: {{ app.selectedUsers | json }}</pre> </div>
</div> <script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.11.2/select.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
UI Select Multiselect - Script Codes CSS Codes
.container { width: 500px; margin: 30px auto;
}
.user-select { width: 60%; float: left;
}
.result { padding-left: 10px; float: left;
}
.mark-all { font-size: 12px; margin: 5px 0;
}
UI Select Multiselect - Script Codes JS Codes
(function () { 'use strict'; angular.module('App', ['ui.select']) .controller('AppCtrl', function (users) { var vm = this; vm.users = users; vm.selectedUsers = []; vm.onUserSelect = function (user) { user.$isSelected = !user.$isSelected; if (user.$isSelected) { vm.selectedUsers.push(user.id); } else { vm.selectedUsers.splice(vm.selectedUsers.indexOf(user.id), 1); } }; vm.getPlaceholder = function () { var length = vm.selectedUsers.length; return length + ' user' + (length !== 1 ? 's' : '') + ' selected'; }; vm.markAllAs = function (selected) { vm.selectedUsers = []; for(var i=0, l=vm.users.length; i<l; i++) { vm.users[i].$isSelected = selected; if (selected) vm.selectedUsers.push(vm.users[i].id); }; }; }) .factory('users', function () { return [ { id:1, name:"Christine Mills" }, { id:2, name:"Nicole Ferguson" }, { id:3, name:"Walter Green" }, { id:4, name:"Theresa Shaw" }, { id:5, name:"Kelly Hudson" }, { id:6, name:"Philip Robinson" }, { id:7, name:"Margaret Weaver" }, { id:8, name:"Frank Harvey" }, { id:9, name:"Jesse Henry" }, { id:10, name:"Norma Collins" }, { id:11, name:"Johnny Richards" }, { id:12, name:"Marilyn Stewart" }, { id:13, name:"Eugene Schmidt" }, { id:14, name:"Stephen Washington" }, { id:15, name:"Christine Allen" }, { id:16, name:"Ryan Mills" }, { id:17, name:"Maria Schmidt" }, { id:18, name:"Janice Gray" }, { id:19, name:"Elizabeth Wright" }, { id:20, name:"Charles Kim" }, { id:21, name:"Charles Jordan" }, { id:22, name:"Lois Ross" }, { id:23, name:"Lillian Griffin" }, { id:24, name:"Gerald Lee" }, { id:25, name:"Ernest Moore" } ]; })
})();
Developer | Chris Hanson |
Username | chrishanson |
Uploaded | October 01, 2022 |
Rating | 3 |
Size | 3,372 Kb |
Views | 30,360 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
A Pen by Chris Hanson | 9,469 Kb |
Custom branding | 9,737 Kb |
Uiselect ie8 issues | 15,255 Kb |
Search bar | 5,899 Kb |
Lf layout | 6,820 Kb |
Css spinner | 2,953 Kb |
Hello World | 3,501 Kb |
Fireworks | 3,514 Kb |
Photo crop prototype | 19,337 Kb |
Particle Emitter | 3,105 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Wikipedia Viewer | Thalpha | 4,426 Kb |
CSS3 Butterfly | Timohausmann | 3,430 Kb |
Compare resources on mobile sites | Gyusza | 3,226 Kb |
Hexagons | Ashmind | 4,360 Kb |
Social Profiles | Lachlanjc | 1,939 Kb |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Dice | Fraina | 5,026 Kb |
Responsive Table-less Shopping Cart | Alex_rodrigues | 6,637 Kb |
Flat design iframe | Damienpm | 1,819 Kb |
React Vote Component | Souporserious | 5,465 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!