@Akinmade Bond
I tried that,and every other combination i could think of but the problem is in the selector
$(".cbRadnikRole:checked")
It gets it right only the first time,and after that is like its late or something.I fixed it,but it has some code duplication.I manually hide what i want outside of the event handler.
$(document).ready(function () {
if ($(".cbRadnikRole:checked").data('id') == 2) {
$('#ulOrgJedinice').show();
}
else {
$('#ulOrgJedinice').hide();
$('#ulOrgJedinice').find("input").attr('checked', false);
}
$(".cbRadnikRole").change(function () {
if ($(this).data('id') == 2) {
$('#ulOrgJedinice').show();
}
else {
$('#ulOrgJedinice').hide();
$('#ulOrgJedinice').find("input").attr('checked', false);
}
});
When i use 'this' it works as it should.