jquery-ui-datepickersammy.js

Datepicker can't work with Sammy.js


i've been using datepicker in many of my projects, but this one project, i've got a problem with it.

the prev/next buttons don't act like it suppose to do. when i clicked it, it redirects to the default page. for example, here is the url where i implemented datepicker

$('input#_date').datepicker();

project.dev/index.html?q=123a21#/home

then, when i click prev/next button, it redirects me to default page which is

project.dev/

i have no idea why this one acts like this. has anyone any idea on how to fix this?

EDITED:

i found out source of the problem but still can't figure out a way to solve it.

everytime i clicked next/prev button on datepicker, it always redirects to default router which is $.sammy.get(''). i found out that prev/next button on datepicker is actually an <a> tag without href attribute.


Solution

  • i managed to solve it eventhough (i still have no idea why it happens) by preventing the default event.

    $('input#_date).datepicker({
         //options
    }).focus(function() {
         $('.ui-datepicker-next, .ui-datepicker-prev').on('click', function(e) {
              e.preventDefault();
         });
    });