Skip to content

Commit 914a40e

Browse files
Update the examples with another way to set the empty value, via the v-model
Signed-off-by: Alexandre Bonneau <[email protected]>
1 parent cd7e2a7 commit 914a40e

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

examples-src/App.vue

+22-8
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
</div>
124124

125125
<div :class="boxClasses" :style="boxStyle">
126-
<div :class="labelClasses">The `id` and `name` passed as props are added onto the generated element</div>
126+
<div :class="labelClasses">The <code>id</code> and <code>name</code> passed as props are added onto the generated element</div>
127127

128128
<div class="inputAndRawValue">
129129
<vue-autonumeric
@@ -137,7 +137,7 @@
137137
</div>
138138

139139
<div :class="boxClasses" :style="boxStyle">
140-
<div :class="labelClasses">Non-input element with the `contenteditable` attribute</div>
140+
<div :class="labelClasses">Non-input element with the <code>contenteditable</code> attribute</div>
141141

142142
<div class="inputAndRawValue">
143143
<vue-autonumeric
@@ -150,7 +150,7 @@
150150
</div>
151151

152152
<div :class="boxClasses" :style="boxStyle">
153-
<div :class="labelClasses">The `placeholder` attribute is passed as a prop too</div>
153+
<div :class="labelClasses">The <code>placeholder</code> attribute is passed as a prop too</div>
154154

155155
<div class="inputAndRawValue">
156156
<vue-autonumeric
@@ -163,7 +163,7 @@
163163
</div>
164164

165165
<div :class="boxClasses" :style="boxStyle">
166-
<div :class="labelClasses">The `options` attribute can be modified <i>on the fly</i>. Click <span class="repoLink" @click="optionsToggle = !optionsToggle">here</span> to toggle it.</div>
166+
<div :class="labelClasses">The <code>options</code> attribute can be modified <i>on the fly</i>. Click <span class="repoLink" @click="optionsToggle = !optionsToggle">here</span> to toggle it.</div>
167167

168168
<div class="inputAndRawValue">
169169
<vue-autonumeric
@@ -176,7 +176,7 @@
176176
</div>
177177

178178
<div :class="boxClasses" :style="boxStyle">
179-
<div :class="labelClasses">The `decimalPlaces` option is <strong>NOT</strong> saved between options updates. Click <span class="repoLink" @click="options2Toggle = !options2Toggle">here</span> to toggle between the states.<br>In order to keep the correct precision, you need to specify the `decimalPlacesRawValue` option for both states.</div>
179+
<div :class="labelClasses">The <code>decimalPlaces</code> option is <strong>NOT</strong> saved between options updates. Click <span class="repoLink" @click="options2Toggle = !options2Toggle">here</span> to toggle between the states.<br>In order to keep the correct precision, you need to specify the <code>decimalPlacesRawValue</code> option for both states.</div>
180180

181181
<div class="inputAndRawValue">
182182
<vue-autonumeric
@@ -189,7 +189,7 @@
189189
</div>
190190

191191
<div :class="boxClasses" :style="boxStyle">
192-
<div :class="labelClasses">Modify the option to 'percentageEU3dec' then set a small value by clicking <span class="repoLink" @click="setOptionsAndValue">here</span>. This <strong>works</strong> even though we do not use a single object to update both options and value at the same time, because the v-model is <strong>not</strong> shared with components having different options.</div>
192+
<div :class="labelClasses">Modify the option to <code>'percentageEU3dec'</code> then set a small value by clicking <span class="repoLink" @click="setOptionsAndValue">here</span>. This <strong>works</strong> even though we do not use a single object to update both options and value at the same time, because the v-model is <strong>not</strong> shared with components having different options.</div>
193193

194194
<div class="inputAndRawValue">
195195
<vue-autonumeric
@@ -202,7 +202,7 @@
202202
</div>
203203

204204
<div :class="boxClasses" :style="boxStyle">
205-
<div :class="labelClasses">Modify the option to 'percentageEU3dec' then set a small value by clicking <span class="repoLink" @click="setOptionsAndValueFail">here</span>. This <strong>fails</strong> since we do not use a single object to update both options and value at the same time, while the v-model is shared with components having different options.</div>
205+
<div :class="labelClasses">Modify the option to <code>'percentageEU3dec'</code> then set a small value by clicking <span class="repoLink" @click="setOptionsAndValueFail">here</span>. This <strong>fails</strong> since we do not use a single object to update both options and value at the same time, while the v-model is shared with components having different options.</div>
206206
<div class="inputAndRawValue">
207207
<vue-autonumeric
208208
:options="options3"
@@ -254,7 +254,16 @@
254254
/>
255255
<div class="rawValue">{{ emptyValue }}</div>
256256
<button class="controls" @click="clearValue">Clear the value with `clear()`</button>
257-
<button class="controls" @click="setToEmptyString">Set to the empty string</button>
257+
<button class="controls" @click="setToEmptyString">Set to the empty string directly</button>
258+
<button class="controls" @click="setToEmptyStringVModel">Set to the empty string with Vue</button>
259+
</div>
260+
</div>
261+
262+
<div :class="boxClasses" :style="boxStyle">
263+
<div :class="labelClasses">Vue-autonumeric that tracks external changes.<br>Try using <code>ext.value = 42</code> in the console.</div>
264+
<div class="inputAndRawValue">
265+
<vue-autonumeric id="ext" :options="{ watchExternalChanges: true }" v-model="externalTracker"/>
266+
<div class="rawValue">{{ externalTracker }}</div>
258267
</div>
259268
</div>
260269
</div>
@@ -280,6 +289,7 @@
280289
autoNumericModel3: 221226.44,
281290
anModel : 42.01,
282291
emptyValue : '',
292+
externalTracker : 1222114.66,
283293
optionsToggle : true,
284294
options2Toggle : true,
285295
options3 : 'euro',
@@ -381,6 +391,10 @@
381391
setToEmptyString() {
382392
AutoNumeric.getAutoNumericElement('#inputToEmpty').set('');
383393
},
394+
395+
setToEmptyStringVModel() {
396+
this.emptyValue = '';
397+
},
384398
},
385399
};
386400
</script>

examples-src/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import Vue from 'vue';
22
import App from './App.vue';
33

4+
Vue.config.devtools = true;
5+
Vue.config.debug = true;
6+
Vue.config.silent = false;
7+
Vue.config.productionTip = true;
8+
49
const app = new Vue({
510
el : '#app',
611
render: h => h(App),

0 commit comments

Comments
 (0)