Reputation: 137
I have some JS that is executing on a datepicker that closes it. Whenever I select a date, it works. When I select the a month or a year from the selectmenu, an event is executing that is focusing off of the datepicker and closes it.
Any suggestions on how to track down this event?
Relevant Code
$(function() {
$(".isDatepicker").datepicker({
changeMonth: true,
changeYear: true,
showOn: "button",
buttonText: "<i class='fa fa-calendar'></i>",
});
});
Upvotes: 0
Views: 442
Reputation: 3454
In answer to the question of how to track it down, Firebug (development tool for Firefox) lets you set a breakpoint on removal or editing of an HTML element. I believe it's in the menu when you click on the element in the DOM tree. And I imagine other browsers have something equivalent.
Upvotes: 1
Reputation: 2223
You are initializing the menu more than once. If you need to refresh it, you can use "refresh":
$(function() {
$(document).on('show.bs.modal', function() {
$("select").selectmenu( "refresh" );
});
$("button.ui-datepicker-trigger").click(function(e) {
$("select").selectmenu( "refresh" );
});
$("select").selectmenu();
$("select").change(function() {
alert("no");
});
});
Upvotes: 0
Reputation: 29683
The problem is with your selectmenu();
initialization on all the select
elements. Here is the updated fiddle where I've commented the selectmenu()
initialization.
Solution would be, you need to target specific select
elements or filter out select
element from datepicker
. The behavior is mixing up within.
Upvotes: 0
Reputation: 5041
You have conflicting scripts I believe.
Remove the code below and it works as designed.
$("button.ui-datepicker-trigger").click(function() {
$("select").selectmenu();
});
Upvotes: 0