v-model property doesn't show inside tinymce - vue.js

I have v-model property, my problem is property doesn't show in tinymce even I can see it in inspect element.
<label>Nama : #{{ adDetailOrder.gajah }}</label>
<input type="text" name="nama" v-model="adDetailOrder.gajah" style="margin-bottom:0px" class="form-control" v-validate.initial="'required|alpha_spaces'" placeholder="Full Name">
<label>#{{ adDetailOrder.gajah }} ... ...</label>
<textarea id="description" class="form-control" rows="3" name="description">... #{{ adDetailOrder.gajah }} ...
</textarea>
Here is my vue
data: {
...
adDetailOrder: {
gajah: '',
}
Here is picture
this is someone is adDetailOrder.gajah
Where I'm doing wrong?
Thanks in advance.

Related

In this code i want to change the variable name 'frontenditems' and 'whoAmI' wheneve i clicked check and radiobutton but it is showing olny on

<template>
<p>FrontEnd Items</p>
<label for="vue">Vue.js</label>
<input type="checkbox" name="vue" id="vue" v-model="frontendItems">
<label for="React">React.js</label>
<input type="checkbox" name="React" id="React" v-model="frontendItems">
<label for="Angular">Angular.js</label>
<input type="checkbox" name="Angular" id="Angular" v-model="frontendItems">
<p>
You have selected :- {{ frontendItems }}
</p>
<p>For radio Buttons</p>
<p>Who am I</p>
<label for="developer">Developer</label>
<input type="radio" name="developer" id="developer" v-model="whoAmI">
<label for="programmer">Programmer</label>
<input type="radio" name="programmer" id="programmer" v-model="whoAmI">
<p>
I am :- {{ whoAmI }}
</p>
</template>
<script>
export default {
name : 'CheckRadiobinding',
data(){
return {
frontendItems:[],
whoAmI : null
}
}
}
</script>
In frontend items i want to get stored array values 'vue', 'react' and 'angular' and in whoAmI varaiable i want to get either developer or programmer whenever i click check and radio button but I am only getting 'on' as a value
You're missing value on each of your inputs. When a checkbox or radio input is selected value is what gets added to your v-model array
<template>
<p>FrontEnd Items</p>
<label for="vue">Vue.js</label>
<input
id="vue"
v-model="frontendItems"
value="Vue.js"
type="checkbox"
name="vue"
/>
<label for="React">React.js</label>
<input
id="React"
v-model="frontendItems"
value="React.js"
type="checkbox"
name="React"
/>
<label for="Angular">Angular.js</label>
<input
id="Angular"
v-model="frontendItems"
value="Angular.js"
type="checkbox"
name="Angular"
/>
<p>You have selected :- {{ frontendItems }}</p>
<p>For radio Buttons</p>
<p>Who am I</p>
<label for="developer">Developer</label>
<input
id="developer"
v-model="whoAmI"
value="Developer"
type="radio"
name="developer"
/>
<label for="programmer">Programmer</label>
<input
id="programmer"
v-model="whoAmI"
value="Programmer"
type="radio"
name="programmer"
/>
<p>I am :- {{ whoAmI }}</p>
</template>

Laravel + vue: Error message only showing the first letter of the sentence

I'm just starting to learn laravel+vue. I was able to follow a tutorial from this yt: https://www.youtube.com/watch?v=JZDmBWRPWlw. Though it seems outdated, I was still able to follow his steps. I'm using the laravel-mix 6.0.6 and vue 2.6.12.
Using inspect element>network, I can see that I'm throwing the correct error message in array.
{"component":"Users\/Create","props":{"app":{"name":"Laravel"},"errors":{"name":"The name field is required.","email":"The email field is required."}},"url":"\/users\/create","version":"207fd484b7c2ceeff7800b8c8a11b3b6"}
But somehow it is not displaying the complete error message. Right now it just show the first letter of the sentence. LOL. Sample error message is: The email field is required and it will just display the letter "T". Below is my Create.vue. Basically it is just a user create form with simple validation.
Create.vue
<template>
<layout>
<div class="container">
<div class="col-md-6">
<div v-if="Object.keys(errors).length > 0" class="alert alert-danger mt-4">
{{ errors[Object.keys(errors)[0]][0] }}
</div>
<form action="/users" method="POST" class="my-5" #submit.prevent="createUser">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name" v-model="form.name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" placeholder="Email" v-model="form.email">
</div>
<div class="form-group">
<label for="name">Password</label>
<input type="password" class="form-control" id="password" placeholder="Password" v-model="form.password">
</div>
<button type="submit" class="btn btn-primary">Create User</button>
</form>
</div>
</div>
</layout>
</template>
<script>
import Layout from '../../Shared/Layout'
export default {
props: ['errors'],
components: {
Layout,
},
data() {
return {
form: {
name: '',
email: '',
password: '',
}
}
},
methods: {
createUser() {
this.$inertia.post('/users', this.form)
.then(() => {
// code
})
}
}
}
</script>
Edit:
I have this error on my console
[Vue warn]: Error in v-on handler: "TypeError: Cannot read property
'then' of undefined"
found in
---> at resources/js/Pages/Users/Create.vue
Your error call is probably getting only the first letter due to [0]. Try to change to:
{{ errors[Object.keys(errors)[0]] }}
Strings can also be read as arrays. If you do this:
$a = "TEST";
echo $a[0];
That would print only T.
That is probably the problem.

Add invalid class to form-group using VueValidate to bootstrap CSS

How to add invalid class to form-group if the validation fails on input. By default VueValidate adds to the input.
<div class="form-group">
<label for="mobile" v-bind:class="{'text-danger': errors.has('mobile')}">Mobile</label>
<input type="text" v-validate="validation.mobile" class="form-control" v-model="user.mobile" name="mobile" id="mobile" />
<span class="invalid-feedback">{{ errors.first('mobile') }}</span>
</div>
Currently i am using v-bind:class="{'text-danger': errors.has('mobile')}" on the label and i get red colored label on field error.
If i could add invalid to form-group, it would be better to control with css. Below is my VueValidate Settings
Vue.use(VeeValidate, {
aria: true,
classes: true,
classNames: {
invalid: 'is-invalid'
}
});
You can bind a computed function to check errors and return the div's classes
{
computed: {
formGroupClass: function () {
if (this.error.has('mobile') ){
return ['form-group', 'invalid']
}
return ['form-group']
}
}
}
<div :class="formGroupClass">
<label for="mobile" v-bind:class="{'text-danger': errors.has('mobile')}">Mobile</label>
<input type="text" v-validate="validation.mobile" class="form-control" v-model="user.mobile" name="mobile" id="mobile" />
<span class="invalid-feedback">{{ errors.first('mobile') }}</span>
</div>

bind v-model to the property which does not exist (Array) in Vue JS

I have some questions getting from the database, It has options also. Then rendering those on the webpage.
like This
<div v-for="(question,index) in questions">
<div class="interview__item-text interview__text-main m-b-20">
{{ index+1 }}. {{ question.question }}
</div>
<div v-for="(option,index) in question.options"
class="reg__form-radioitem" :key="index">
<div>
<input class="checkbox countable__input"
v-model="question.answer"
:value="option.option"
type="checkbox"
:id="question.id+option.id">
<label :for="question.id+option.id">
{{ option.option }}
</label>
</div>
</div>
</div
This is working fine for input type text and radio but for checkbox it does not work. It checks all the checkboxes in that loop.
question.answer does not exist on the data.i am trying to add new property answer using v-model
Thanks.
Maybe you can try to predefine the question.answer, should exist after this:
data: {
question: {
answer: null
}
}
Try this.
<input class="checkbox countable__input"
v-model="question[answer]"
:value="option.option"
type="checkbox"
:id="question.id+option.id">
<label :for="question.id+option.id">
{{ option.option }}
</label>

Vue Validator only after change / blur / submit

I'm using Vue for the first time, with Vue Validator. Here is an example of my code:
<label for="first_name">First name:
<span v-if="$validation1.first_name.required" class="invalid">Enter your first name.</span>
<input id="first_name" placeholder="e.g. Christopher" class="" v-validate:first_name="['required']" v-model="first_name" name="first_name" type="text">
</label>
The only issue at the moment is that when I land on the page with my form, the whole thing is covered in errors. Is there a way I can suppress the errors and only show them on input blur / form submit?
Argh, the Google-able word isn't about blur, or on submit – its about timing and initial:
http://vuejs.github.io/vue-validator/en/timing.html
<input id="first_name" initial="off" placeholder="e.g. Christopher" class="" v-validate:first_name="['required']" v-model="first_name" name="first_name" type="text">
you need to add .dirty or .touched to your validation
<label for="first_name">First name:
<span v-if="$validation1.first_name.required && $validation1.first_name.touched" class="invalid">Enter your first name.</span>
<input id="first_name" placeholder="e.g. Christopher" class="" v-validate:first_name="['required']" v-model="first_name" name="first_name" type="text">
</label>
I was dealing with a similar problem. I had to have an initialized variable for the input name: "" but I also wanted to have a required attribute in element.
So I add required when the event onblur occurs.
<input name="name" type="number" v-model="name" #blur="addRequired" />
const app = Vue.createApp({
data() {
return {
name: ""
}
},
methods:{
addRequired: function(event){
event.target.setAttribute("required", true);
}
}
});