Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#employee_id').select2({
- placeholder: 'Select Employee Type',
- width: '100%',
- allowClear: true,
- ajax: {
- url: backend_url + '/employee/get_employee',
- dataType: 'json',
- delay: 300,
- type: 'POST',
- data: function(params) {
- return {
- search: params.term, // search term
- // _token: $('meta[name="csrf-token"]').attr('content'),
- // _method: 'POST',
- emp_type: $('#emp_type').val(),
- department: $('#department').val(),
- page: params.current_page,
- }
- },
- processResults: function(data, params) {
- params.current_page = params.current_page || 1;
- var res = data.data.map(function(item) {
- return {
- id: item.id,
- text: item.name,
- max_advanced: item.max_advanced
- };
- });
- return {
- results: res,
- pagination: {
- more: (params.current_page * 10) < data.total
- }
- };
- },
- cache: true
- },
- templateResult: function(data) {
- if (!data.id) {
- return data.text;
- }
- var $result = $('<span>' + data.text + '</span>');
- $result.attr('data-salary', data.max_advanced);
- return $result;
- },
- templateSelection: function(data) {
- if (!data.id) {
- return data.text;
- }
- return data.text;
- },
- }).on('select2:select', function(event) {
- // On Change Event Code Here Selected Data
- });
- // Get Selected Data Attribute Value Get
- $("#employee_id").select2('data')[0].max_advanced
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement