Bootstrap-datepicker: adding bootstrap-datepicker in a bootstrap modal that has 'show.bs.modal' event confilicting with datepicker's show event results to trigger modal's event

Created on 23 Oct 2015  路  5Comments  路  Source: uxsolutions/bootstrap-datepicker

Hi there, I have a bootstrap modal that has a event for 'show.bs.modal'. it loads a form via ajax, and this form has a datepicker object.
everytime you click on datepicker it triggers bootstrap modal's 'show.bs.modal' event. that results reloading form. again.

Most helpful comment

This worked for me

$(your-date-picker).on("show", function(e){
     e.preventDefault();
     e.stopPropagation();
}).on("hide", function(e){
     e.preventDefault();
     e.stopPropagation();
});

All 5 comments

Any workaround for this 'bug'?

Actually for workaround this issue, I changed my bootstrap event from 'show.bs.modal' to 'shown.bs.modal', I know this is not a solve for this problem, but for now I'm waiting for boostrap-datepicker to solve it.

This worked for me

$(your-date-picker).on("show", function(e){
     e.preventDefault();
     e.stopPropagation();
}).on("hide", function(e){
     e.preventDefault();
     e.stopPropagation();
});

thanks !

not sure if the same solution can be applied (as I took zellerda's solution which worked for me) but
https://github.com/uxsolutions/bootstrap-datepicker/pull/642/commits/8b5d19b84d9e1f3163c5ec880bf94d5f70d80029

refers to namespacing the events.
https://github.com/uxsolutions/bootstrap-datepicker/pull/642

I'm not able to try out a similar solution at the moment, but might be a good fit for the next person coming along here looking for alternatives.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Erwane picture Erwane  路  6Comments

mrlife picture mrlife  路  4Comments

aifrim picture aifrim  路  5Comments

jneuhaus picture jneuhaus  路  3Comments

alvarotrigo picture alvarotrigo  路  4Comments