How can I extend a UI component JavaScript in Magento 2?
This can be accomplished using a requirejs "mixin".
First create Your_Module/view/base/requirejs-config.js
with this code:
var config = {
'config': {
'mixins': {
'Magento_Ui/js/form/form': {
'Your_Module/form-hook': true
}
}
}
};
Now make the file Your_Module/view/base/web/form-hook.js
:
define([], function () {
'use strict';
return function (Form) {
return Form.extend({
initialize: function () {
this._super();
console.log('Hello from the mixin!');
}
});
}
});
This example extends the initialize method of the form
component.
You can read more about "mixins" here: http://alanstorm.com/the-curious-case-of-magento-2-mixins/