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
Post a Comment