javascript - Jquery - .prop not checking my input checkbox dynamically -


i have simple data table added checkboxes can select. have edit button show details of data. have set everytime hit edit pull data ajax , fill it's fields , checkboxes accordingly.

the issue have checkboxes. @ moment saving functionality working great. use below code determine if checkboxes checked or not , returns true or false in database.

candidat_gestion_de_problème: $("#candidat_gestion_de_problème").prop( "checked" )  

the issue following code, when hit edit button pulls data database:

$("#candidat_gestion_de_problème").prop( "checked", incident.candidat_gestion_de_problème ); 

note: incident.candidat_gestion_de_problème returns true or false. had them tested in console , spitting out.

in cases if database returns false, .prop seems ignore , leaves checkbox checked.

when perform same code manually in console works fine:

$("#candidat_gestion_de_problème").prop( "checked", false ); 

would understand why this?

well sadirubaiyet had interessting aproach tweaked slighty , worked:

$("#candidat_gestion_de_problème").prop( "checked", incident.candidat_gestion_de_problème == "true" ? true : false ); 

i hoping avoid method don't see way around @ moment. guys.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -