Last active
January 13, 2016 19:07
-
-
Save n1lux/2c34cf8c09cf933ee19f to your computer and use it in GitHub Desktop.
checkboxes from json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************** | |
Build checkboxes | |
params: obj= threat object, | |
list_all_input = all inputs received, | |
checkbox_id = checkbox id | |
type=type data | |
*********************************************************************/ | |
function build_checkboxes(obj, list_all_input, array_checked_obj, checkbox_id, type_data){ | |
/* Build control types checkboxes */ | |
$(checkbox_id).empty(); | |
var list_checked = []; | |
var check = '' | |
$.each(array_checked_obj, function(){ | |
list_checked.push(this.id); | |
} | |
); | |
$.each(list_all_input, function () { | |
if ($.inArray(this.id, list_checked) == -1){ | |
check = false; | |
}else{ | |
check = true; | |
} | |
$(checkbox_id).append( | |
$("<div>").addClass("col-lg-4").prepend( | |
$("<label>").addClass("checkbox-inline i-checks").text(this.name).prepend( | |
$("<input>").attr({'type':'checkbox', 'name':type_data}).val(this.id).prop('checked', check) | |
) | |
) | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment