vue-datetime icon indicating copy to clipboard operation
vue-datetime copied to clipboard

can it run off a button instead of an input field?

Open bloukrans opened this issue 7 years ago • 5 comments

bloukrans avatar Jan 26 '18 09:01 bloukrans

Sounds good, I thought three options:

  • Add a simply property to draw a button instead of an input

If we want to be more customizable we can:

  • Add a slot to override the input
  • Or add a property no-input or similar and another one to set the open status

What do you think?

mariomka avatar Jan 26 '18 10:01 mariomka

option two sounds most flexible

would be good to have a short chat about it. how can I contact you?

bloukrans avatar Jan 27 '18 01:01 bloukrans

Just to leave this here, you can accomplish it this way:

In the template:

<button @click="openPicker">Open it!</button>
<datetime
  ref="date-picker"
  v-model="date" />

In Methods:

openPicker () {
  this.$refs['date-picker'].$el.firstChild.click()
}

In your CSS:

.vdatetime-input {
  display: none;
}

zombeej avatar Aug 07 '18 20:08 zombeej

This would be a really handy feature and would un-bind the datetime popup control from the input field. There are so many cases that a datetime picker is needed without an input field. @zombeej solution/hack does not work for me, it throws an error (Uncaught TypeError: this.$refs['datepicker'].$el.firstChild.click is not a function with the right datetime ref="datepicker") and there is also a problem with bootstap 4 modal, because the overlay fixed position actually fits inside the modal instead of the whole window and in cases like this one, would be nice to have the picker popup independently without an input or to bind it to another input.

EDIT My workaround for bootstrap 4 modal is to add the datetime component outside the modal, hide the input like @zombeej does, add highther than boostrap modal z-index for both vdatetime-overlay and vdatetime-popup classes and call this.$refs.datepicker.open(event); bind to focus event on an input field inside the modal. It works for me, but it would be really nice to have it working with no need of an input control.

clytras avatar Nov 03 '18 22:11 clytras

This would be a really handy feature and would un-bind the datetime popup control from the input field. There are so many cases that a datetime picker is needed without an input field. @zombeej solution/hack does not work for me, it throws an error (Uncaught TypeError: this.$refs['datepicker'].$el.firstChild.click is not a function with the right datetime ref="datepicker") and there is also a problem with bootstap 4 modal, because the overlay fixed position actually fits inside the modal instead of the whole window and in cases like this one, would be nice to have the picker popup independently without an input or to bind it to another input.

EDIT My workaround for bootstrap 4 modal is to add the datetime component outside the modal, hide the input like @zombeej does, add highther than boostrap modal z-index for both vdatetime-overlay and vdatetime-popup classes and call this.$refs.datepicker.open(event); bind to focus event on an input field inside the modal. It works for me, but it would be really nice to have it working with no need of an input control.

This helped me a lot. Must be added to the docs.

giacomotontini avatar Oct 22 '19 14:10 giacomotontini