Permalink
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...
1 parent 8b627ca commit 2be9ce5102e36789c07b2473ab19806001bb622d Ethan committed Dec 15, 2010
Showing with 14 additions and 1 deletion.
  1. +14 −1 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");

0 comments on commit 2be9ce5

Please sign in to comment.