Auto Check Dynamic Check boxes
Auto Check Dynamic Check boxes
I have made dynamic check boxes using:
{label:'Users',
name:'rightsManagement[].users',
type:'checkbox'
}
This will accept simple json structured like this:
{
"rights": {
"users": [{"label": "Insert","value":0},{"label":"Update","value":1}]"
}
}
which can be passed like this:
editor.field('rightsManagement[].users').update(json.rights.users);
My issue is, is there an api to auto check the check box or I will just have to settle with jquery?
This discussion has been closed.
Replies
Auto check it with what? You can set a value using the
field().val()
method. For the above you could pass in an array of the values that you want to have changed and you could do that immediately after yourfield().update()
call.Allan
Allan thank you for your quick response. I want to set the check boxes with value:1 to html "checked". I know can update the boxes with field().update(). That is how I pass the values in the first place. What I want to know is how to marked required check boxes with "checked" using an editor api? I know i can use jquery by looping over json and check for those with 1 as value then mark them like this ("selector").prop("checked",true), however is there an equivalent editor api for doing this?
Does the
field().val()
method not do that for you?Simply
editor.field('myField').val([1]);
should do it.Allan