-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
anyone managed to implement this successfully as vue js component? #97
Comments
Hi, You can have a look at the options I set, some are customizations and some are workarounds for issues I encountered. Hopefully you will find it helpful :) <template>
<span class="ui calendar field">
<label>
<slot>Datum :</slot>
</label>
<div class="ui input left icon">
<i class="calendar icon"></i>
<input type="text" placeholder="Datum" :class="{wideCalendar: showTime}">
</div>
</span>
</template>
<script>
import $ from 'jquery'
import moment from 'moment'
moment.locale('hr')
export default {
name: 'calendar',
props: ['value', 'specialDays', 'inline', 'showField', 'showTime'],
mounted () {
$(this.$el).calendar({
specialDays: this.specialDays,
type: this.showTime ? 'datetime' : 'date', // picker type, can be 'datetime', 'date', 'time', 'month', or 'year'
firstDayOfWeek: 1, // day for first day column (0 = Sunday)
constantHeight: true, // add rows to shorter months to keep day calendar height consistent (6 rows)
today: true, // show a 'today/now' button at the bottom of the calendar
inline: this.inline, // create the calendar inline instead of inside a popup
disableYear: true, // disable year selection mode
multiMonth: 1, // show multiple months when in 'day' mode
text: {
days: ['N', 'P', 'U', 'S', 'Č', 'P', 'S'],
months: ['Siječanj', 'Veljača', 'Ožujak', 'Travanj', 'Svibanj', 'Lipanj', 'Srpanj', 'Kolovoz', 'Rujan', 'Listopad', 'Studeni', 'Prosinac'],
monthsShort: ['Sij', 'Velj', 'Ožu', 'Tra', 'Svi', 'Lip', 'Srp', 'Kol', 'Ruj', 'Lis', 'Stu', 'Pro'],
today: 'Danas',
now: 'Sada',
am: 'AM',
pm: 'PM'
},
ampm: false, // show am/pm in time mode
// callback when date changes, return false to cancel the change
onChange: (date, text, mode) => {
// console.log('chnge:' + date)
this.$emit('input', date)
this.$emit('change')
},
parser: {
date: function (text, settings) {
// return a date parsed from 'text'
return moment(text).toDate()
}
}
})
if (this.value) {
// console.log('mount:' + this.value)
$(this.$el).calendar('set date', this.value)
$(this.$el).calendar('refresh')
}
},
destroyed () {
$(this.$el).off()
}
}
</script>
<style>
.wideCalendar {
min-width: 250px;
}
</style> Please note, that I used also some custom options (i.e. specialDays) which are processed elsewhere... |
@ndamjan could you show how did you import the module to your vue project? When I try
I get an 'calendar is not a function' error, no matter what :( |
@ploissken Here is what I can find in the project where it's used...
import 'semantic-calendar-css'
import 'semantic-calendar' Please be aware that this was from a project which uses older webpack version (1.14.0) so config will probably look a bit different now. Hope this helps! |
I`m trying to implement it as vuejs component like below.
Any idea on what `m doing wrong here?
The text was updated successfully, but these errors were encountered: