How can I extend modal in bootstrap 4?

Firstly, I have a problem with OOP in javascript and I understand very little about it, but I need to solve the problem ...

Well, I'm trying to use the Bootstrap 3 library in Bootstrap 4: https://github.com/nakupanda/bootstrap3-dialog

I get the following error: "Unable to call class as function"

Looking at the code, I found something:

1 - classCallCheck: this is a function that throws an error. I believe this forces the user to use the β€œnew” and instantiate the object and never call it as a function;

2 - createClass: this is a function that builds classes, so classes in Bootstrap 4 are not conditionally defined.

3 - inherits: this is another function and shows that inheritance is also not ordinary.

4 - The library has this code to extend Bootstrap modality:

var BootstrapDialogModal = function (element, options) { Modal.call(this, element, options); }; 

But Modal.call causes an error: "It is impossible to call a class as a function."

I suppose the only problem is that BootstrapDialogModal inherits Modal under the inheritance conditions imposed by Bootstrap 3, and when Bootstrap 4 is active, these conditions do not match.

Follow jsfiddle: http://jsfiddle.net/g6nrnvwu/

Does anyone know how I can configure this code?

Thanks.

+5
source share
2 answers

You can see this pull request, the purpose of which is to upgrade the plugin to BS 4: https://github.com/nakupanda/bootstrap3-dialog/pull/281/files?diff=unified

+1
source

Well, this is not exactly the answer, but an example that can help you. This is the class I made to handle modal dynamic insertion of its markup on the fly. This is not BS4, but you can use it as a guide, maybe?

Modal utils

+1
source

Source: https://habr.com/ru/post/1272079/


All Articles