Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I work on a MVC project and make a mvc site as application.

At the moment I want this button to pop up a calender menu:
<a class="calender-button" href="#"><img src="~/Content/images/icon-calendar.png" /></a>


I'm using the Bootstrap 3 Datepicker
Posted
Updated 29-Sep-15 23:38pm
v5
Comments
Thanks7872 30-Sep-15 6:12am    
And? What is your question?

1 solution

You can set a hidden input and on click of it show the datetimepicker like:

HTML:
HTML
<a class="calender-button" href="#">
   Click Here
</a>
<input type="hidden" id="yourField" />


JS:
JavaScript
$('#yourField').datetimepicker();
$('.calender-button').click(function (e) {
    e.preventDefault();
    $('#yourField').data("DateTimePicker").toggle();
});
 
Share this answer
 
Comments
Wessel Beulink 30-Sep-15 6:31am    
Uncaught TypeError: Cannot read property 'toggle' of undefined

included the .js of the datepicker. Datetimepicker is not valid because i don't have a datetimepicker in my project files. It's returning me te follow error when i use it on datepicker. Removed the toggle and the defaults of the function. still not showing me what is suppose to do.

Already check the bundleconfig on failures but can't find it so far.

bundleconfig:

bundles.Add(new ScriptBundle("~/bundles/timepicker").Include(
"~/Scripts/bootstrap-datepicker.js"));

and the render:

@Scripts.Render("~/bundles/timepicker")
Palash Mondal_ 30-Sep-15 6:36am    
Sorry my bad you have told that you are using bootstrap-datetimepicker.js but in the code you are using bootstrap-datepicker.js. It's much easier with datepicker. you can just use shownOn property here. Hope you can take it from here.
Wessel Beulink 30-Sep-15 7:08am    
Yes Thanks <3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900