Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function($) {$('.dropdown-toggle').dropdown('toggle');});
- $('#ajax_local, #ajax_servico, #ajax_persquisador').multiselect({
- /**/
- includeSelectAllOption: true,
- nSelectedText: 'selecionados ..',
- nonSelectedText:'Nenhum selecionado ..',
- allSelectedText: 'Todos selecionados ..',
- selectAllText: 'Selecionar todos ..',
- numberDisplayed: 1,
- });
- // ...
- $('#ajax_empresa').multiselect({
- /**/
- includeSelectAllOption: true,
- nSelectedText: 'selecionados ..',
- nonSelectedText:'Nenhum selecionado ..',
- allSelectedText: 'Todos selecionados ..',
- selectAllText: 'Selecionar todos ..',
- numberDisplayed: 1,
- onDropdownHide: function(option, checked){
- // ...
- MultiselectSet($("#ajax_persquisador"));
- MultiselectSet($("#ajax_servico"));
- MultiselectSet($("#ajax_local"));
- // ...
- var empresas = [];
- $("#ajax_empresa option:selected").each(function(){
- var empresa = $(this).val();
- empresas.push(empresa);
- });
- // Se empresa vazia ...
- if(empresas.length == 0){
- $("#ajax_local, #ajax_servico, #ajax_persquisador").multiselect('destroy');
- $.ajax({
- url: '/ajaxrequests/reset',
- type: 'POST'
- });
- }
- // ...
- $.ajax({
- url: '/ajaxrequests/requestlocals',
- type: 'POST', dataType: 'json',
- data: {empresas:empresas},
- success: function(retorno){
- var locals = retorno.locals;
- var checks = retorno.check;
- //console.log(retorno);
- $('#ajax_local').html("");
- $.each(locals, function(valor, chave){
- $('#ajax_local').append($('<option>', {
- value: valor,
- text : chave,
- checked: checks[valor],
- selected: checks[valor]
- }));
- });
- $("#ajax_local").multiselect('destroy');
- MultiselectSet($("#ajax_local"));
- }
- });
- // ...
- $.ajax({
- url: '/ajaxrequests/requestpesquisadores',
- type: 'POST', dataType: 'json',
- data: {empresas:empresas},
- success: function(retorno){
- var pesqs = retorno.pesquisadores;
- var checks = retorno.check;
- //console.log(retorno);
- $('#ajax_persquisador').html("");
- $.each(pesqs, function(valor, chave){
- $('#ajax_persquisador').append($('<option>', {
- value: valor,
- text : chave,
- checked: checks[valor],
- selected: checks[valor]
- }));
- });
- $("#ajax_persquisador").multiselect('destroy');
- MultiselectSet($("#ajax_persquisador"));
- }
- });
- // ...
- $.ajax({
- url: '/ajaxrequests/requestservicos',
- type: 'POST', dataType: 'json',
- data: {empresas:empresas},
- success: function(retorno){
- var servs = retorno.servicos; // [10, 12, 14, 20, 21, 23, 25, 29, 32, 33, 38, 45]
- var checks = retorno.check; // [10, 12, 14, 20, 21, 23, 25]
- console.log(retorno);
- $('#ajax_servico').html("");
- $.each(servs, function(valor, chave){
- $('#ajax_servico').append($('<option>', {
- value: valor,
- text : chave,
- checked: checks[valor],
- selected: checks[valor]
- }));
- });
- $("#ajax_servico").multiselect('destroy');
- MultiselectSet($("#ajax_servico"));
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement