Serhioromano / bootstrap-calendar

Full view calendar with year, month, week and day views based on templates with Twitter Bootstrap.
http://bootstrap-calendar.eivissapp.com/
MIT License
3.02k stars 1.29k forks source link

Override defaults and options values outside of app.js #526

Open cvcv01 opened 9 years ago

cvcv01 commented 9 years ago

How can I override the tmpl_path, day, event_source values outside of app.js?

When defined this way, I get the calendar, but I can't override the values in app.js using the values below:

<script type="text/javascript" src="{{asset('/bootstrap-calendar/js/calendar.js')}}"></script>
<script type="text/javascript">
    var calendar = $('#calendar').calendar({
    tmpl_path: "./bootstrap-calendar/tmpls/",
    day: "2015-01-01",
    events_source: [
        {
            "id": 293,
            "title": "Event 1",
            "url": "http://example.com",
            "class": "event-important",
            "start": 1437507900000, // Milliseconds 
            "end":   1437508639654 // Milliseconds
        }
    ]
    });
</script>
<script type="text/javascript" src="{{asset('/bootstrap-calendar/js/app.js')}}"></script>

If I reference app.js before the calendar function (see below), it breaks the calendar

<script type="text/javascript" src="{{asset('/bootstrap-calendar/js/calendar.js')}}"></script>
<script type="text/javascript" src="{{asset('/bootstrap-calendar/js/app.js')}}"></script>
<script type="text/javascript">
    var calendar = $('#calendar').calendar({
    tmpl_path: "./bootstrap-calendar/tmpls/",
    day: "2015-01-01",
    events_source: [
        {
            "id": 293,
            "title": "Event 1",
            "url": "http://example.com",
            "class": "event-important",
            "start": 1437507900000, // Milliseconds 
            "end":   1437508639654 // Milliseconds
        }
    ]
    });
</script>

If I comment out these variables in app.js (see below), it breaks the calendar too

var options = {
    // events_source: 'events.json.php',
    view: 'month',
    // tmpl_path: './bootstrap-calendar/tmpls/',
    tmpl_cache: false,
    // day: '2015-07-24',

Any ideas? Thanks guys

eleazan commented 9 years ago

App.js is only an example (and be the initialitazion for the example web...)

You don't need to call it, or use it ;)

cvcv01 commented 9 years ago

I understand, thanks. I thought I would be able to comment out lines in app.js (i like for setting default values) to be able to provide values outside of app.js. No problem Thanks