Skip to content

Commit 510b7dd

Browse files
committed
decouple events array from calendar vue object
update readme and package.json to reflect moving events to app root
1 parent e6890f1 commit 510b7dd

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

README.md

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,74 @@ OR you can include the compiled file found in "dist/vbc.js" directly into your p
2323
</div>
2424

2525
<div id="app">
26-
<Calendar :first-day="0"></Calendar>
26+
<Calendar
27+
:first-day="1"
28+
:all-events="events"
29+
></Calendar>
2730
</div>
2831
</div>
2932
<script src="dist/vbc.js"></script>
3033
<script>
3134
var app = new Vue( {
32-
el : '#app',
33-
i18n,
34-
mounted() {
35-
let loadingIndicator = document.getElementById( "loading" );
36-
if(loadingIndicator != null){
37-
loadingIndicator.style.display = "none";
38-
}
39-
}
40-
} );
35+
el : '#app',
36+
data: {
37+
events: []
38+
},
39+
i18n,
40+
mounted() {
41+
let loadingIndicator = document.getElementById( "loading" );
42+
43+
if(loadingIndicator != null){
44+
loadingIndicator.style.display = "none";
45+
}
46+
47+
this.events = [ // you can make ajax call here
48+
{
49+
id:1,
50+
title:'Event 1',
51+
color: 'panel-danger',
52+
date: new Date()
53+
},
54+
{
55+
id:2,
56+
title:'Event blaa on same day!',
57+
color: 'panel-default',
58+
date: new Date()
59+
},
60+
{
61+
id:3,
62+
title:'Event 2',
63+
color: 'panel-primary',
64+
date: new Date(new Date().setHours(new Date().getHours() + 2*24)) // add 2 days
65+
},
66+
{
67+
id:4,
68+
title:'Event 3',
69+
color: 'panel-success',
70+
date: new Date(new Date().setHours(new Date().getHours() + 5*24)) // add 5 days
71+
},
72+
{
73+
id:5,
74+
title:'Event 4',
75+
color: 'panel-warning',
76+
date: new Date(new Date().setHours(new Date().getHours() + 14*24)) // add 2 weeks
77+
},
78+
{
79+
id:6,
80+
title:'Event 5',
81+
color: 'panel-success',
82+
date: new Date(new Date().setHours(new Date().getHours() + 30*24)) // add 1 month
83+
},
84+
85+
];
86+
}
87+
} );
4188
</script>
4289
```
4390

4491
## How to use vue-bootstrap-calendar #
45-
Simply include ```<Calendar :first-day="x"></Calendar>``` in your vue app. ``x`` is an integer for the start of the week, which can be one of the following values ``0,1,2,3,4,5,6``, where 0 for Sunday, 1 for Monday and so on...
92+
Simply include ```<Calendar :first-day="x" :all-events="events"></Calendar>``` in your vue app. ``x`` is an integer for the start of the week, which can be one of the following values ``0,1,2,3,4,5,6``, where 0 for Sunday, 1 for Monday and so on...
93+
Events array can passed on via ``all-events`` binding.
4694

4795

4896
## Copyright and License

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-bootstrap-calendar",
33
"description": "Uses the magical power of VueJS v2 and beauty of Twitter Bootstraps to create a powerful Responsive Calendar App.",
4-
"version": "1.0.0",
4+
"version": "1.0.2",
55
"author": "yarob <eazyserver.net@gmail.com>",
66
"homepage": "https://github.com/EazyServer/Vue-Bootstrap-Calendar",
77
"repository": {

0 commit comments

Comments
 (0)