0

I am having trouble opening a modal in Microsoft Edge only.

The link to open the modal is:

<%= link_to the_path, class: "btn btn-tertiary class-used-to-find-the-link", data: {"things-id" => 4, "other-things-id" => 7} do %>
  <span>The Link's Text</span>
<% end %>

The JavaScript for the link is:

$('class-used-to-find-the-link').click(onClick);

The onClick method mentioned above would be something like:

onClick   =   function(event) { 
                 //blah..blah...blah
              };

The .click does not get triggered in IE Edge only but works in all other browsers. This link above is supposed to open a modal. I have other instances of .click that don't open modals and these are fine.

So, I think it may be related to the discussion here: Microsoft Edge: onclick event stops working?. Similar to the post linked, when I refresh the page the link does work and the modal opens.

Also, if I firstly open the page that contains the link to click in another tab, via right click and 'Open In New Tab', then the link will also work.

I have tried some of the answers in the post I have linked, including mousedown and mouseup but these didn't work.

Any help is appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
atw
  • 5,428
  • 10
  • 39
  • 63
  • It says the bug is fixed in build 34.x https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5782378/. – Ruan Mendes Jan 11 '17 at 12:45
  • I am not 100% sure that my issue is the same as the one linked in my question. Also my Microsoft Edge version is 38.14393.0.0 and Microsoft EdgeHTML is 14.14393. – atw Jan 11 '17 at 13:43

1 Answers1

0

This was being caused by Turbolinks and was not related to the SO question and answer here: Microsoft Edge: onclick event stops working?. So, in a way the comment of the link here: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5782378/ was valid.

I disabled Turbolinks in the same fashion and in the answer here: https://stackoverflow.com/a/27196250/1945948

Specifically, the issue was being caused by how turbolinks and event handlers combine. An alternative to disabling Turbolinks would be to use delegated event handling. Here, is a good article on delegated event handlers: https://www.iexposure.com/industry-insights/rails-4-turbolinks-and-delegated-event-handling-in-jquery.

Community
  • 1
  • 1
atw
  • 5,428
  • 10
  • 39
  • 63