diff --git a/src/views/PasswordGenerator.vue b/src/views/PasswordGenerator.vue index ebc0021..86e6ff6 100644 --- a/src/views/PasswordGenerator.vue +++ b/src/views/PasswordGenerator.vue @@ -176,17 +176,6 @@ }); }, mounted(){ - const self = this; - new Awesomplete(this.$refs.site, { - list: this.passwords.map(password => { - return {label: password.site + ' ' + password.login, value: password} - }), - replace: function (password) { - self.$store.dispatch('savePassword', {password: password.value}); - this.input.value = password.value.site; - } - }); - if (this.password.site) { this.$refs.login.focus(); } else { @@ -205,6 +194,21 @@ } }, watch: { + 'passwords': function (passwords) { + var site = document.getElementById('site'); + const self = this; + if (site !== null && passwords.length > 0) { + new Awesomplete(site, { + list: passwords.map(password => { + return {label: password.site + ' ' + password.login, value: password} + }), + replace: function (password) { + self.$store.dispatch('savePassword', {password: password.value}); + this.input.value = password.value.site; + } + }); + } + }, 'password.site': function () { this.cleanErrors(); },