简体   繁体   中英

Replacing Pop-Up window with Bootstrap Modal

I want to replace a pop up window with a modal in a web application. The previous implementation uses JQuery $j('input field name', opener.document); to access values stored on the previous, parent screen - this doesn't work with a modal implementation, it throws an

Uncaught TypeError: Cannot read property 'document' of null

Can anyone suggest an alternative for opener.document for use with Bootstrap Modal?

Thanks in advance

The code you posted is to short to give an good answer.

but i can give you an fiddle with a modal taking text from outside it.

Now i dont know what you mean by previous, parent screen.

But what i think your after is: Finding something on that's outside the modal and place it inside.

Jquery:

var text = $('some-where-you-want-info-from').html();
$('modal-body').prepend(text);`

This gets some html from an element and sets it to the modal body

I think the best solution is with the following syntax:

var myVar = window.parent.document.getElementById('element_name');

which seems to copy the value over exactly!

Big thanks to Persijn for pointing me in the right direction with this one!

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