Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Problem getting updated value from child component to the parent component in a Laravel 9 with Vue

<template>
    <div class="input-group  input-group-merge mb-3">
        <input
            v-model="postalCode"
            type="text" class="form-control"
            id="postal_code" name="postal_code"
        />
    </div>
</template>

<script>
export default {
    name: "PostalCode",

    props: {
        modelValue: String,
    },

    data() {
        return {
            postalCode: null
        }
    },

    watch: {
        // watching prop
        modelValue: {
            handler: function (newValue) {
                if (newValue) {
                    this.postalCode = newValue;
                }
            },
            immediate: true,
        },

       // watching data() property
        postalCode: {
            handler: function (newValue, old) {            
                this.$emit('update:modelValue', newValue)
            },
            immediate: true
        }
    }
}
</script>

//and use
<postal-code v-model="user.postal_code"/>
Comment

PREVIOUS NEXT
Code Example
Php :: if cat 1 then send email woocommerce functions 
Php :: store data array in php of input field 
Php :: laravel nova create resource 
Php :: function placing bet using php 
Php :: Using a variable outside of the while loop (scope) 
Php :: how to add accept and decline button in php form 
Php :: import csv laravel 
Php :: another query to get user details 
Php :: how to include page specific css in xphp smart header 
Php :: expiry date alert in php 
Php :: Check box group submit (php) 
Php :: spatie/laravel-health 
Php :: php generator for mysql 
Php :: how to get the top_area in orders laravel 
Php :: set renew subscroption stripe update 
Php :: iterate collection laravel 
Php :: Laravel Exclude URI from csrf token verification 
Php :: laravel add model to polymorphic relationships 
Php :: Formatting an Excel Column 
Php :: How to return custom error message from controller method validation 
Php :: Define Events in Model 
Php :: Final class constants - PHP 8.1 
Php :: php spellchecker 
Php :: how to add user profile image in my account page in woocommerce 
Php :: laravel pagination bootstrap sorting column 
Php :: laravel rename file ftp 
Php :: remove public from laravel 8 url 
Php :: count same datetimes in foreach and group them php 
Php :: laravel get referer without host 
Php :: php href variable in javascript alert 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =