Close modal dialog when opening link in new browser tab/window

Phipsen

I'd like to close the modal bootstrap dialog when the user hits "Open ticket", which in turn opens a new browser window/tab. Here is my button:

<%= link_to content_tag(:i, '', class: "fa fa-ticket") + "Open ticket",
      "https://link.to/another/company/url",
      target: '_blank',
      class: 'btn btn-default' 
%>

This works fine, but when returning to the calling page, the modal is still open.

I tried to add data: { dismiss: 'modal' }, but then the link isn't being opened.

Thanks.

Shehary

Can suggest you solution,

if you trying like this data: { dismiss: 'modal' } you should try like this

<%= link_to content_tag(:i, '', class: "fa fa-ticket") + "Open ticket",
      "https://link.to/another/company/url",
      target: '_blank',
      class: 'btn btn-default',
      data-dismiss: 'modal'
%>

Alternate you can do with jQuery, as you have class selector here class: 'btn btn-default' in button to open the link

<%= link_to content_tag(:i, '', class: "fa fa-ticket") + "Open ticket",
      "https://link.to/another/company/url",
      target: '_blank',
      class: 'btn btn-default' 
%>

Add a customer selector e.g close-modal, like class: 'btn btn-default close-modal'

and bind the jQuery with selector close-modal to close the modal when button clicked.

$(document).ready(function() {
    $('.close-modal').click(function(){
        $('#modalid').modal('hide');  //change #modalid to your bootstrap modal id
    });
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Close modal dialog when opening link in new browser tab/window

From Dev

MSAL browser dialog close

From Dev

Angular close modal dialog when pressing escape in Chrome and Safari

From Dev

Angular close modal dialog when pressing escape in Chrome and Safari

From Dev

Vue.js 2: Modal Dialog - close when Method is successful

From Dev

Opening a link in a different browser

From Dev

How to close the respective modal dialog when switch over to other modal dialog without overlapping - using Bootsrap 3

From Dev

Is it possible to fire a modal when the user attempts to close the browser with AngularJS?

From Dev

SSL error when opening link in python. Works fine in browser

From Dev

SSL error when opening link in python. Works fine in browser

From Dev

Showing an Alert Dialog before opening a new activity when Button is Click

From Dev

How to prevent parent activity of a dialog to show when opening new activity?

From Dev

Showing an Alert Dialog before opening a new activity when Button is Click

From Dev

Opening a new browser tab

From Dev

Auto-close NERDTree when opening file in new tab

From Dev

how to close a modal dialog in showEvent?

From Dev

ember modal dialog wont close

From Dev

Javascript Close Modal Window When Any Link is Clicked

From Dev

"Close Firefox" error on opening a link

From Dev

Opening Modal Window from Link

From Dev

opening a link in a new window

From Dev

How to close an application or modal dialog via the taskbar when the dialog's ShowInTaskBar = false?

From Dev

How to close an application or modal dialog via the taskbar when the dialog's ShowInTaskBar = false?

From Dev

What is the HTTP referrer for Firefox when opening a link in a new tab?

From Dev

Wicket why page expires when opening link in new tab?

From Dev

opening jquery modal dialog on page load

From Dev

opening jquery modal dialog on page load

From Dev

How to open new window browser when user click close tab?

From Dev

Opening a link in a new tab is working for Firefox but not working for Chrome browser using Selenium

Related Related

  1. 1

    Close modal dialog when opening link in new browser tab/window

  2. 2

    MSAL browser dialog close

  3. 3

    Angular close modal dialog when pressing escape in Chrome and Safari

  4. 4

    Angular close modal dialog when pressing escape in Chrome and Safari

  5. 5

    Vue.js 2: Modal Dialog - close when Method is successful

  6. 6

    Opening a link in a different browser

  7. 7

    How to close the respective modal dialog when switch over to other modal dialog without overlapping - using Bootsrap 3

  8. 8

    Is it possible to fire a modal when the user attempts to close the browser with AngularJS?

  9. 9

    SSL error when opening link in python. Works fine in browser

  10. 10

    SSL error when opening link in python. Works fine in browser

  11. 11

    Showing an Alert Dialog before opening a new activity when Button is Click

  12. 12

    How to prevent parent activity of a dialog to show when opening new activity?

  13. 13

    Showing an Alert Dialog before opening a new activity when Button is Click

  14. 14

    Opening a new browser tab

  15. 15

    Auto-close NERDTree when opening file in new tab

  16. 16

    how to close a modal dialog in showEvent?

  17. 17

    ember modal dialog wont close

  18. 18

    Javascript Close Modal Window When Any Link is Clicked

  19. 19

    "Close Firefox" error on opening a link

  20. 20

    Opening Modal Window from Link

  21. 21

    opening a link in a new window

  22. 22

    How to close an application or modal dialog via the taskbar when the dialog's ShowInTaskBar = false?

  23. 23

    How to close an application or modal dialog via the taskbar when the dialog's ShowInTaskBar = false?

  24. 24

    What is the HTTP referrer for Firefox when opening a link in a new tab?

  25. 25

    Wicket why page expires when opening link in new tab?

  26. 26

    opening jquery modal dialog on page load

  27. 27

    opening jquery modal dialog on page load

  28. 28

    How to open new window browser when user click close tab?

  29. 29

    Opening a link in a new tab is working for Firefox but not working for Chrome browser using Selenium

HotTag

Archive