diff --git a/src/components/checkbox/Checkbox.vue b/src/components/checkbox/Checkbox.vue
index d4aa9fc7b..2b5e1563e 100644
--- a/src/components/checkbox/Checkbox.vue
+++ b/src/components/checkbox/Checkbox.vue
@@ -21,7 +21,8 @@ export default {
inputId: String,
autofocus: Boolean,
autocomplete: String,
- disabled: Boolean
+ disabled: Boolean,
+ binary: Boolean
},
model: {
prop: 'modelValue',
@@ -37,15 +38,15 @@ export default {
if (!this.disabled) {
let newModelValue;
- if (Array.isArray(this.modelValue)) {
+ if (this.binary) {
+ newModelValue = !this.modelValue;
+ }
+ else {
if (this.checked)
newModelValue = this.modelValue.filter(val => !ObjectUtils.equals(val, this.value));
else
newModelValue = this.modelValue ? [...this.modelValue, this.value] : [this.value];
}
- else {
- newModelValue = !this.modelValue;
- }
this.$emit('click', event);
this.$emit('input', newModelValue);
@@ -64,7 +65,7 @@ export default {
},
computed: {
checked() {
- return Array.isArray(this.modelValue) ? ObjectUtils.contains(this.value, this.modelValue) : this.modelValue;
+ return this.binary ? this.modelValue : ObjectUtils.contains(this.value, this.modelValue);
}
}
}
diff --git a/src/views/checkbox/CheckboxDoc.vue b/src/views/checkbox/CheckboxDoc.vue
index 632c4e743..e5fdf9f48 100644
--- a/src/views/checkbox/CheckboxDoc.vue
+++ b/src/views/checkbox/CheckboxDoc.vue
@@ -10,7 +10,7 @@ import Checkbox from 'primevue/checkbox';
Getting Started
Checkbox can either be used in multiple selection with other checkboxes or as a single checkbox to provide a boolean value.
-<Checkbox id="binary" inputId="binary" v-model="checked" />
+<Checkbox v-model="checked" :binary="true" />
Multiple Values
@@ -32,77 +32,69 @@ export default {
}
-
As v-model is two-way binding enabled, prepopulating the model array with values is enough to display the related
checkboxes as checked by default.
-
-export default {
- data() {
- return {
- themes: [{name: 'Apollo', key: 'A'}, {name: 'Babylon', key: 'B'}, {name: 'Serenity', key: 'S'}, {name: 'Ultima', key: 'U'}],
- selectedThemes: []
- }
- },
- created() {
- this.selectedThemes = this.themes.slice(1,3);
- }
-}
-
Properties
-
- Name |
- Type |
- Default |
- Description |
-
+
+ Name |
+ Type |
+ Default |
+ Description |
+
-
- inputId |
- string |
- null |
- Unique identifier of the inner native checkbox. |
-
-
- value |
- any |
- null |
- Value of the checkbox. |
-
-
- name |
- string |
- null |
- Name of the checkbox element . |
-
-
- disabled |
- boolean |
- false |
- When present, it specifies that the element value cannot be altered. |
-
-
- modelValue |
- any |
- null |
- Value of the checkbox. |
-
-
- autocomplete |
- string |
- null |
- When specifies, whether or not an the element should have autocomplete enabled. |
-
-
- autofocus |
- boolean |
- false |
- When present, it specifies that the element should automatically get focus when the page loads. |
-
+
+ inputId |
+ string |
+ null |
+ Unique identifier of the inner native checkbox. |
+
+
+ value |
+ any |
+ null |
+ Value of the checkbox. |
+
+
+ name |
+ string |
+ null |
+ Name of the checkbox element . |
+
+
+ disabled |
+ boolean |
+ false |
+ When present, it specifies that the element value cannot be altered. |
+
+
+ modelValue |
+ any |
+ null |
+ Value of the checkbox. |
+
+
+ autocomplete |
+ string |
+ null |
+ Whether an the element should have autocomplete enabled. |
+
+
+ autofocus |
+ boolean |
+ false |
+ When present, it specifies that the element should automatically get focus when the page loads. |
+
+
+ binary |
+ boolean |
+ false |
+ Allows to select a boolean value instead of multiple values. |
+
@@ -111,38 +103,38 @@ export default {
-
- Name |
- Parameters |
- Description |
-
+
+ Name |
+ Parameters |
+ Description |
+
-
- change |
- event: Browser event |
- Callback to invoke on value change. |
-
-
- input |
- event: Value of checkbox |
- Callback to invoke on click. |
-
-
- click |
- event: Browser event |
- Callback to invoke click. |
-
-
- focus |
- event: Browser event |
- Callback to invoke on focus. |
-
-
- blur |
- event: Browser event |
- Callback to invoke on blur. |
-
+
+ change |
+ event: Browser event |
+ Callback to invoke on value change. |
+
+
+ input |
+ event: Value of checkbox |
+ Callback to invoke on click. |
+
+
+ click |
+ event: Browser event |
+ Callback to invoke click. |
+
+
+ focus |
+ event: Browser event |
+ Callback to invoke on focus. |
+
+
+ blur |
+ event: Browser event |
+ Callback to invoke on blur. |
+
@@ -152,28 +144,28 @@ export default {
-
- Name |
- Element |
-
+
+ Name |
+ Element |
+
-
- p-chkbox |
- Container element |
-
-
- p-chkbox-box |
- Container of icon. |
-
-
- p-chkbox-icon |
- Icon element. |
-
-
- p-chkbox-label |
- Label element. |
-
+
+ p-chkbox |
+ Container element |
+
+
+ p-chkbox-box |
+ Container of icon. |
+
+
+ p-chkbox-icon |
+ Icon element. |
+
+
+ p-chkbox-label |
+ Label element. |
+
diff --git a/src/views/radiobutton/RadioButtonDoc.vue b/src/views/radiobutton/RadioButtonDoc.vue
index a83881baf..a2d81afd8 100644
--- a/src/views/radiobutton/RadioButtonDoc.vue
+++ b/src/views/radiobutton/RadioButtonDoc.vue
@@ -37,56 +37,56 @@ export default {
-
- Name |
- Type |
- Default |
- Description |
-
+
+ Name |
+ Type |
+ Default |
+ Description |
+
-
- inputId |
- string |
- null |
- Unique identifier of the inner native radiobutton. |
-
-
- name |
- string |
- null |
- Name of the checkbox element . |
-
-
- value |
- any |
- null |
- Value of the radiobutton. |
-
-
- disabled |
- boolean |
- false |
- When present, it specifies that the element value cannot be altered. |
-
-
- modelValue |
- any |
- null |
- Value of the checkbox. |
-
-
- autofocus |
- boolean |
- null |
- When present, it specifies that the element should automatically get focus when the page loads. |
-
-
- autocomplete |
- string |
- null |
- When specifies, whether or not an the element should have autocomplete enabled. |
-
+
+ inputId |
+ string |
+ null |
+ Unique identifier of the inner native radiobutton. |
+
+
+ name |
+ string |
+ null |
+ Name of the checkbox element . |
+
+
+ value |
+ any |
+ null |
+ Value of the radiobutton. |
+
+
+ disabled |
+ boolean |
+ false |
+ When present, it specifies that the element value cannot be altered. |
+
+
+ modelValue |
+ any |
+ null |
+ Value of the checkbox. |
+
+
+ autofocus |
+ boolean |
+ null |
+ When present, it specifies that the element should automatically get focus when the page loads. |
+
+
+ autocomplete |
+ string |
+ null |
+ Whether or not an the element should have autocomplete enabled. |
+
@@ -95,38 +95,38 @@ export default {
-
- Name |
- Parameters |
- Description |
-
+
+ Name |
+ Parameters |
+ Description |
+
-
- change |
- event: Browser event |
- Callback to invoke on value change. |
-
-
- input |
- event: Value of checkbox |
- Callback to invoke on click. |
-
-
- click |
- event: Browser event |
- Callback to invoke click. |
-
-
- focus |
- event: Browser event |
- Callback to invoke on focus. |
-
-
- blur |
- event: Browser event |
- Callback to invoke on blur. |
-
+
+ change |
+ event: Browser event |
+ Callback to invoke on value change. |
+
+
+ input |
+ event: Value of checkbox |
+ Callback to invoke on click. |
+
+
+ click |
+ event: Browser event |
+ Callback to invoke click. |
+
+
+ focus |
+ event: Browser event |
+ Callback to invoke on focus. |
+
+
+ blur |
+ event: Browser event |
+ Callback to invoke on blur. |
+
@@ -136,28 +136,28 @@ export default {
-
- Name |
- Element |
-
+
+ Name |
+ Element |
+
-
- p-radiobutton |
- Container element |
-
-
- p-radiobutton-box |
- Container of icon. |
-
-
- p-radiobutton-icon |
- Icon element. |
-
-
- p-radiobutton-label |
- Label element. |
-
+
+ p-radiobutton |
+ Container element |
+
+
+ p-radiobutton-box |
+ Container of icon. |
+
+
+ p-radiobutton-icon |
+ Icon element. |
+
+
+ p-radiobutton-label |
+ Label element. |
+
diff --git a/src/views/tristatecheckbox/TriStateCheckboxDoc.vue b/src/views/tristatecheckbox/TriStateCheckboxDoc.vue
index 2fdd022c5..90988f391 100644
--- a/src/views/tristatecheckbox/TriStateCheckboxDoc.vue
+++ b/src/views/tristatecheckbox/TriStateCheckboxDoc.vue
@@ -17,50 +17,50 @@ import TriStateCheckbox from 'primevue/tristatecheckbox';
-
- Name |
- Type |
- Default |
- Description |
-
+
+ Name |
+ Type |
+ Default |
+ Description |
+
-
- inputId |
- string |
- null |
- Unique identifier of the native checkbox element. |
-
-
- value |
- any |
- null |
- Value of the TriStateCheckbox. |
-
-
- name |
- string |
- null |
- Name of the checkbox element . |
-
-
- disabled |
- boolean |
- false |
- When present, it specifies that the element value cannot be altered. |
-
-
- autocomplete |
- string |
- null |
- When specifies, whether or not an the element should have autocomplete enabled. |
-
-
- autofocus |
- boolean |
- false |
- When present, it specifies that the element should automatically get focus when the page loads. |
-
+
+ inputId |
+ string |
+ null |
+ Unique identifier of the native checkbox element. |
+
+
+ value |
+ any |
+ null |
+ Value of the TriStateCheckbox. |
+
+
+ name |
+ string |
+ null |
+ Name of the checkbox element . |
+
+
+ disabled |
+ boolean |
+ false |
+ When present, it specifies that the element value cannot be altered. |
+
+
+ autofocus |
+ boolean |
+ false |
+ When present, it specifies that the element should automatically get focus when the page loads. |
+
+
+ autocomplete |
+ string |
+ null |
+ Whether an the element should have autocomplete enabled. |
+
@@ -69,38 +69,38 @@ import TriStateCheckbox from 'primevue/tristatecheckbox';
-
- Name |
- Parameters |
- Description |
-
+
+ Name |
+ Parameters |
+ Description |
+
-
- change |
- event: Browser event |
- Callback to invoke on value change. |
-
-
- input |
- event: Value of checkbox |
- Callback to invoke on click. |
-
-
- click |
- event: Browser event |
- Callback to invoke click. |
-
-
- focus |
- event: Browser event |
- Callback to invoke on focus. |
-
-
- blur |
- event: Browser event |
- Callback to invoke on blur. |
-
+
+ change |
+ event: Browser event |
+ Callback to invoke on value change. |
+
+
+ input |
+ event: Value of checkbox |
+ Callback to invoke on click. |
+
+
+ click |
+ event: Browser event |
+ Callback to invoke click. |
+
+
+ focus |
+ event: Browser event |
+ Callback to invoke on focus. |
+
+
+ blur |
+ event: Browser event |
+ Callback to invoke on blur. |
+
@@ -110,28 +110,28 @@ import TriStateCheckbox from 'primevue/tristatecheckbox';
-
- Name |
- Element |
-
+
+ Name |
+ Element |
+
-
- p-chkbox |
- Container element |
-
-
- p-tristatechkbox |
- Container element |
-
-
- p-chkbox-box |
- Container of icon. |
-
-
- p-chkbox-icon |
- Icon element. |
-
+
+ p-chkbox |
+ Container element |
+
+
+ p-tristatechkbox |
+ Container element |
+
+
+ p-chkbox-box |
+ Container of icon. |
+
+
+ p-chkbox-icon |
+ Icon element. |
+