简体   繁体   中英

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.

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

你可以看看这个旨在将插件更新到BS 4的拉取请求: https//github.com/nakupanda/bootstrap3-dialog/pull/281/files?dififf = unified

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM