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 |
Hello World | 3,501 Kb |
Custom branding | 9,737 Kb |
Lf layout | 6,820 Kb |
Nested rotating shapes | 2,646 Kb |
Ui-select with tree navigation | 5,321 Kb |
Fireworks | 3,514 Kb |
Uiselect ie8 issues | 15,255 Kb |
Css spinner | 2,953 Kb |
Rotating 3d cube | 2,957 Kb |
Photo crop prototype | 19,337 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 |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
Animated rainbow wave on canvas | Icodeforlove | 2,777 Kb |
Vue.js | Thommyboy02 | 1,506 Kb |
Multicolumns 2 | Raphaelgoetter | 1,857 Kb |
Tab panels | Accessibility | 0 Kb |
Lecture 1 | Law | 0 Kb |
Custom checkbox example | Capelo | 3,495 Kb |
Rrremark.com Overlay Highlighter | Derickruiz | 4,438 Kb |
Cant get enough icecream in pure css3 | Melawire | 4,322 Kb |
Cofee and sugar | Tripack | 2,094 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!