How to override JavaScript safely

116 Views Asked by At

My goal : Prevent Dropdrop from closing if an input control in focus inside the drop down pane.

I've found that if I comment out the following lines, it prevents the dropdown pane from closing in all cases. So, I've isolated the code which I want to modify.

https://github.com/zurb/foundation-sites/blob/v6.5.0-rc.3/js/foundation.dropdown.js#L161-L165 https://github.com/zurb/foundation-sites/blob/v6.5.0-rc.3/js/foundation.dropdown.js#L172-L176

I'm using gulp/npm workflow. I don't want to modify the original files inside node_modules.

Question: How do I safely override _events in the Dropdown class? Should I override the entire property?

Foundation.Dropdown.prototype._events = function(){
  // my modified code here?
}

The above method works but I was wondering if it's the right way. Is there any other way through which I could just turn off the events on the specific elements?

0

There are 0 best solutions below