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

Reload page when button clicked #404

Closed giopierini closed 9 years ago

giopierini commented 10 years ago

Hi, i used your calendar in my custom CRM, but i have a problem when i click on the buttons on top for change month/year, go to the next etc etc. when every button is clicked, first works fine, i can see the calendar change, but after that the browser starts to reload a page. i don't know if there is conflict with some my script, but i use your same version of bootstrap (3) and jquery. i tried with preventdefault(). if i use it the window doesn't reload, but the calendar doesn't change...how i can stop the page realoading? Thanks!

eleazan commented 10 years ago

You are missing something. How do you initialize these buttons?

I doen't have problems... :/

giopierini commented 10 years ago

I think is the same of the example inside the packet...

var calendar = $('#calendar').calendar(options);

$('.btn-group button[data-calendar-nav]').each(function() {
    var $this = $(this);
    $this.click(function() {
        calendar.navigate($this.data('calendar-nav'));
    });
});

$('.btn-group button[data-calendar-view]').each(function() {
    var $this = $(this);
    $this.click(function() {
        calendar.view($this.data('calendar-view'));
    });
});
alexrqs commented 10 years ago

@giopierini can you simulate the same on jsfiddle.com to share the URL?

giopierini commented 9 years ago

i solved! the problem was the button html tag, my calendar is inside a form, and when i click the button the form was submitted... i solved changing button with span, now it work fine...thank you anyway!

Serhioromano commented 9 years ago

i solved changing button with span, now it work fine...thank you anyway!

Better just add attribute to button type="button" and it will stop submitting the form. Because by default button type is submit.