Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix calendar_date_select's method of firing onChange for its target e…

…lement.

the current method only looks at the 'onchange' property of the target element. this means that if any events are add using Event.observe (in prototype - or addEventListener / attachEvent outside prototype), they are not fired when the date is selected.
this is updated to fire the onchange event on the element, rather than calling the onchange function.
  • Loading branch information...
commit 2be9ce5102e36789c07b2473ab19806001bb622d 1 parent 8b627ca
Ethan authored
Showing with 14 additions and 1 deletion.
  1. +14 −1 public/javascripts/calendar_date_select/calendar_date_select.js
View
15 public/javascripts/calendar_date_select/calendar_date_select.js
@@ -88,7 +88,20 @@ CalendarDateSelect.prototype = {
minute_interval: 5,
popup_by: this.target_element,
month_year: "dropdowns",
- onchange: this.target_element.onchange,
+ onchange: function(target_element)
+ { return function()
+ { if(target_element.dispatchEvent)
+ { var event=document.createEvent('HTMLEvents');
+ event.initEvent('change', true, true);
+ target_element.dispatchEvent(event);
+ }
+ else
+ { var event=document.createEventObject();
+ event.type='onChange';
+ target_element.fireEvent('onChange', event);
+ }
+ };
+ }(this.target_element),
valid_date_check: nil
}).merge(options || {});
this.use_time = this.options.get("time");
Please sign in to comment.
Something went wrong with that request. Please try again.