You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it seems like it's not possible to check checkboxes or radio buttons with DisplayJS based on a variable, like in the following example: https://jsfiddle.net/jgb0qc38/
Is there another way to do this?
This might be related to #37 - the checked attribute, I guess.
The text was updated successfully, but these errors were encountered:
There is definitely a way to this, but not with DisplayJS currently. Here is a little plugin that you can use to render radio checkboxes:
$.fn.radioRender=function(push){// the functionconstvar_push=()=>{this.if();this.else();constelements=document.querySelectorAll("[var]");for(leti=0;i<elements.length;i++){constattr=elements[i].getAttribute("var");if(!attr.includes(".")){if(elements[i].type=="radio"){elements[i].checked=this.obj[attr]}else{elements[i].innerHTML=this.obj[attr];}}else{constparts=attr.split(".");letval=this.obj[parts[0]];for(letp=1;p<parts.length;p++){val=val[parts[p]];}if(elements[i].type=="radio"){elements[i].checked=val}else{elements[i].innerHTML=val}}}};// push var chekingif(!push){var_push();}elseif(push==true){var_push();this.live(this.obj,()=>{var_push();});}else{window.setInterval(()=>{var_push();},push);}}
I'm not closing this issue as I definitely need to upgrade the $.var() function. As I'm a bit busy and not really working on DisplayJS lately, submitting a PR would help a lot. Thank you very much for telling me about this issue.
Hi,
it seems like it's not possible to check checkboxes or radio buttons with DisplayJS based on a variable, like in the following example:
https://jsfiddle.net/jgb0qc38/
Is there another way to do this?
This might be related to #37 - the checked attribute, I guess.
The text was updated successfully, but these errors were encountered: