vuejs-directive

vue2js - how to propagate selected index with chosen select value in a direcitve

隐身守侯 提交于 2019-12-24 08:59:51
问题 Please look at the code below. The first select box is created with chosen js. When changed it should propagate its changed value to the model to which its bound ( cityid ). The second normal select box is working fine and its value is propagated. Vue.directive('chosen', { bind: function (el, binding, vnode, oldVnode) { Vue.nextTick(function() { $(el).chosen({ width:'100%' }).change(function(){ alert($(el).val()); vnode.context.$emit('input', $(el).val()); }); }); }, update: function(el,

Using intl-tel-input and vuejs2 together

怎甘沉沦 提交于 2019-12-23 12:06:14
问题 I am trying to implement https://github.com/jackocnr/intl-tel-input with vuejs2 . If I add inside one jQuery document.ready , $('#phone').intlTelInput({ options...}) Everything works as expected but when I'm trying to fetch the value of the input field and some boolean valid property, I am always checking the value one step behind. My checking method looks like: validatePhoneNumber: function() { var validPhoneNo = $("#phone").intlTelInput("isValidNumber"); var phoneNo = $("#phone")

Extend vueJs directive v-on:click

ⅰ亾dé卋堺 提交于 2019-12-08 21:57:50
问题 I'm new to vuejs. I'm trying to create my first app. I would like to show a confirm message on every click on buttons. Example: <button class="btn btn-danger" v-on:click="reject(proposal)">reject</button> My question is: Can I extend the v-on:click event to show the confirm everywhere? I would make my custom directive called v-confirm-click that first executes a confirm and then, if I click on "ok", executes the click event. Is it possible? 回答1: I would recommend a component instead.

A custom directive similar to v-if in vuejs

爱⌒轻易说出口 提交于 2019-12-04 16:21:18
问题 I'm writing a custom directive in vue. I want it to work like v-if but it will have a little logic going inside it. Let me explain with an example: <button v-permission="PermissionFoo">Do Foo</button> It will check the permission and will show or hide the component. Currently I'm doing this via CSS styles: var processPermissionDirective = function (el, binding, vnode) { if (SOME_LOGIC_HERE) { el.style.display = el._display; } else { el.style.display = 'none'; } } export default { bind:

A custom directive similar to v-if in vuejs

喜欢而已 提交于 2019-12-03 10:16:41
I'm writing a custom directive in vue. I want it to work like v-if but it will have a little logic going inside it. Let me explain with an example: <button v-permission="PermissionFoo">Do Foo</button> It will check the permission and will show or hide the component. Currently I'm doing this via CSS styles: var processPermissionDirective = function (el, binding, vnode) { if (SOME_LOGIC_HERE) { el.style.display = el._display; } else { el.style.display = 'none'; } } export default { bind: function (el, binding, vnode) { el._display = el.style.display; processPermissionDirective(el, binding, vnode