Есть табы, которые скрыты, при клике по элементу с нужным атрибутом, таб появляется. Как такой код, можно сократить? Причём, чем короче получится, тем лучше.
$(document).ready(function() {
$(".style_of_tabs").hide();
});
$(document).on('click', '.tab_add', function (){
var post = {};
post.ajaxRequest = true;
$metod = $(this).data('metod');
if($metod == 'country'){
$('#country').show();
post.country = true;
}
if($metod == 'currenci'){
$('#currenci').show();
post.currenci = true;
}
if($metod == 'package'){
$('#package').show();
post.package = true;
}
if($metod == 'activitidirection'){
$('#activitidirection').show();
post.activitidirection = true;
}
if($metod == 'branch'){
$('#branch').show();
post.branch = true;
}
if($metod == 'industrialdirection'){
$('#industrialdirection').show();
post.industrialdirection = true;
}
if($metod == 'measuri'){
$('#measuri').show();
post.measuri = true;
}
if($metod == 'fo'){
$('#fo').show();
post.fo = true;
}
if($metod == 'region'){
$('#region').show();
post.region = true;
}
if($metod == 'logistic'){
$('#logistic').show();
post.logistic = true;
}
if($metod == 'quality'){
$('#quality').show();
post.quality = true;
}
$(this).hide();
console.log(post);
var result = sendAjaxRequest({
url: '/infobase/getTabs',
data: post
});
});
$metod
, то их можно заменить чем-то таким:$('#' + $metod).show(); post[$metod] = true;