Comments (7)
I have the same problem. Is there any solution?
from datetime-picker.
@matepaiva @icolquemamani @fooloomanzoo
did you found any solutions? I am using Stencil.js and also don't know how to get current date
from datetime-picker.
Nope! I just used another package, unfortunately.
from datetime-picker.
@qweluke @matepaiva
I have a partial solution, use the component in a class of polymer 3 without a lit-element, reuse the same in the class with lit-element. Manage to capture the date through personalized events.
<calendar-element auto-confirm date="{{date}}" min="{{min}}" first-day-of-week="0"></calendar-
element>
static get properties() {
return {
date: {
type: String,
notify: true,
observer: '_dateChanged'
},
min: {
type: String
}
};
}
_dateChanged(newValue, oldValue) {
let event = new CustomEvent('change', {
detail: { date: newValue }
});
this.dispatchEvent(event);
}
I'm not sure if this can help you with the library that you are currently using "stencil.js".
from datetime-picker.
@matepaiva which package?
from datetime-picker.
Give this a try:
firstUpdated() {
super.firstUpdated();
let dtPicker = this.shadowRoot.querySelector('datetime-picker');
dtPicker.shadowRoot.querySelector('button#confirm').addEventListener('click', () => {
this.dispatchEvent(new CustomEvent('change', {
detail: dtPicker
}));
})
}
We've just needed to do something similar. In this case we're wrapping it in a lit-element component so we're passing the change event up to the parent.
If you are directly using the component from the same context you'd probably want something like:
firstUpdated() {
super.firstUpdated();
let dtPicker = this.shadowRoot.querySelector('datetime-picker');
dtPicker.shadowRoot.querySelector('button#confirm').addEventListener('click', () => {
this._handleDateChanged(dtPicker);
})
}
_handleDateChanged(dtPicker) {
console.dir(dtPicker);
}
All of the parameters which you can get out are visible in the Developer Console in Chrome etc.
from datetime-picker.
After poking around in the source code of @fooloomanzoo/property-mixins/datetime-mixin
and reading some Polymer documentation, I found that the property datetime
has notify: true
; so we can in fact listen for the datetime-changed
custom event:
<datetime-picker
datetime=${this.dateFrom}
@datetime-changed=${e => this.dateFrom = e.target.datetime}
></datetime-picker>
It would be good to document all of the events available (or at least the more useful ones). As it stands it's quite hard to discover how to use this component outside of Polymer apps - it feels like a shame to throw away the versatility of being a portable webcomponent.
EDIT: This also isn't a perfect solution, since this event is fired not only on user input but also when the prop changes for any other reason, such as being programmatically updated, and on component initialization.
from datetime-picker.
Related Issues (20)
- DatetimePolyfillPickerMixin is not set on the window object like other mixins. HOT 1
- Polymer 3.0 support? HOT 6
- Feature request: hide reset button HOT 1
- Quitting editing, or resetting field to null HOT 1
- Feature request: fire event on value reset HOT 2
- Clamp values incorrect in the documentation HOT 1
- calendar-element When confirm, it autoSubmit form HOT 3
- Calandar element submit my form automatically HOT 1
- Change width of overlay-datetime-picker HOT 1
- npm installation fails HOT 2
- i've got a widget I need HOT 1
- Typing values manually HOT 6
- Style input to fit Twitter Bootstrap HOT 1
- Dead links in readme.md
- ES6 with Polymer 2 HOT 1
- input-picker-closed Not Triggering Function
- date-picker Stops Navigating
- Not able to use with-timezone , errors if the timezone is active
- Disable double click feature
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datetime-picker.