Skip to content

Instantly share code, notes, and snippets.

@Sarapulov
Created November 19, 2017 17:56
Show Gist options
  • Save Sarapulov/941e7e06dee7ac615a8bc84714e71e64 to your computer and use it in GitHub Desktop.
Save Sarapulov/941e7e06dee7ac615a8bc84714e71e64 to your computer and use it in GitHub Desktop.
set and unset checkbox on Web Widget
// set and unset checkbox on Web Widget
// jQuery is epxected
// fieldHandler.setCheckbox("45510285"); // call to set
// fieldHandler.unsetCheckbox("45510285"); // call to unset
var fieldHandler = (function() {
return {
getCheckbox: function(field_id) {
return $("iframe#webWidget").contents().find('input[name='+field_id+']');
},
setCheckbox: function(field_id) {
this.getCheckbox(field_id) && this.getCheckbox(field_id).prop('value', "1").prop('checked', true).next().find('span').removeClass('src-component-field-Checkbox-checkmarkUnchecked u-isHiddenVisually');;
},
unsetCheckbox: function(field_id) {
this.getCheckbox(field_id) && this.getCheckbox(field_id).prop('value', "0").prop('checked', false).next().find('span').addClass('src-component-field-Checkbox-checkmarkUnchecked u-isHiddenVisually');;
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment