Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I extends a Modal in Bootstrap 4?

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

Well, I am trying use, on Bootstrap 4, a library made for Bootstrap 3: https://github.com/nakupanda/bootstrap3-dialog

I get the following error: "Cannot call a class as a function"

Looking the code, I discovered somethings:

1 - classCallCheck: is the function that throws the error. I suppose that it forces the user use "new" and instantiate an object and never call like a function;

2 - createClass: is a function that constructs classes, so the classes in Bootstrap 4 is not defined conventionally.

3 - inherits: is another function and shows that the inheritance is not conventional too.

4 - The library has this code to extends the Bootstrap Modal:

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

But, Modal.call trigger the error: "Cannot call a class as a function".

I suppose the only problem is BootstrapDialogModal inherits Modal in inheritance conditions imposed by Bootstrap 3 and, when Bootstrap 4 is active, these conditions are not the same.

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

Someone know how can I adjust this code?

Thanks.

like image 859
Doglas Avatar asked Sep 24 '17 15:09

Doglas


2 Answers

You may take a look at this pull request that aims to update the plugin to BS 4: https://github.com/nakupanda/bootstrap3-dialog/pull/281/files?diff=unified

like image 183
Mohamed Chaawa Avatar answered Oct 09 '22 12:10

Mohamed Chaawa


Ok it's not exactly an answer, but an example that maybe can help you. This is a class i made to handle modal dynamically inserting it's markup on the fly. It's not BS4 but you can use as a guide maybe?

ModalUtils

like image 35
Marco Avatar answered Oct 09 '22 10:10

Marco