Skip to content

Commit 7f2537a

Browse files
committed
Add country-changed event
1 parent 47e46e4 commit 7f2537a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ Read more on `vue-form-generator`'s [instruction page](https://icebob.gitbooks.i
9696

9797
| Property value | Type | Default value | Description |
9898
| -------------- | ---- | ------------- | ----------- |
99-
| `defaultCountry` | `string` | `''` | Default country, will override the country fetched from IP address of user |
100-
| `disabledFetchingCountry` | `Boolean` | false | Disable fetching current country based on IP address of user |
99+
| `defaultCountry` | `String` | `''` | Default country, will override the country fetched from IP address of user |
100+
| `disabledFetchingCountry` | `Boolean` | `false` | Disable fetching current country based on IP address of user |
101101
| `disabled` | `Boolean` | `false` | Disable input field |
102102
| `disabledFormatting` | `Boolean` | `false` | Disable formatting the phone number in the input, the formatted result still be accessible by `formattedNumber` returned from `onInput` event |
103-
| `placeholder` | `string` | Enter a phone number | Placeholder for the input |
103+
| `placeholder` | `String` | Enter a phone number | Placeholder for the input |
104104
| `required` | `Boolean` | `false` | Required property for HTML5 required attribute |
105105
| `enabledCountryCode` | `Boolean` | `false` | Enable country code in the input |
106106
| `enabledFlags` | `Boolean` | `true` | Enable flags in the input |
@@ -110,8 +110,8 @@ Read more on `vue-form-generator`'s [instruction page](https://icebob.gitbooks.i
110110
| `autocomplete` | `String` | `'on'` | Native input 'autocomplete' attribute |
111111
| `name` | `String` | `'telephone'` | Native input 'name' attribute |
112112
| `maxLen` | `Number` | `25` | Native input 'maxlength' attribute |
113-
| `wrapperClasses` | `String | Array | Object` | `''` | Custom classes for the wrapper |
114-
| `inputClasses` | `String | Array | Object` | `''` | Custom classes for the `input` |
113+
| `wrapperClasses` | `String` | `Array` | `Object` | `''` | Custom classes for the wrapper |
114+
| `inputClasses` | `String` | `Array` | `Object` | `''` | Custom classes for the `input` |
115115
| `inputId` | `String` | `''` | Custom 'id' for the `input` |
116116
| `dropdownOptions` | `Object` | `{ disabledDialCode: false, tabindex: 0 }` | Options for dropdown, supporting `disabledDialCode` and `tabindex`|
117117
| `inputOptions` | `Object` | `{ showDialCode: false, tabindex: 0 }` | Options for input, supporting `showDialCode` (always show dial code in the input) and `tabindex`|
@@ -128,6 +128,7 @@ Read more on `vue-form-generator`'s [instruction page](https://icebob.gitbooks.i
128128
| `enter` | | Fires on keyup.enter event | `onEnter` deprecated |
129129
| `open` | | Fires when the flags dropdown opens | |
130130
| `close` | | Fires when the flags dropdown closes | |
131+
| `country-changed` | `Object` | Fires when country changed (even for the first time) | Available from `v2.4.2` |
131132

132133
## Highlights & Credits
133134
- Telephone Number parsing, validation by [libphonenumber-js](https://catamphetamine.github.io/libphonenumber-js/).

src/vue-tel-input.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ export default {
401401
this.$nextTick(() => { this.phone = oldValue; });
402402
}
403403
},
404+
activeCountry(value) {
405+
if (value && value.iso2) {
406+
this.$emit('country-changed', value);
407+
}
408+
},
404409
},
405410
mounted() {
406411
this.initializeCountry();

0 commit comments

Comments
 (0)