jquery-ujs
jquery-ujs copied to clipboard
Disable with not working on IE11 (W8.1)
The issue is that "some times" (read ~= 1 of 20) clicks do disable the link, but do not navigate. The link is disabled so the user cannot try again so it is very annoying. It depends on the time you keep the mouse down and if you click over the text. I also have a click sound being triggered and it also get triggered, but there is no navigation. Does anyone have a clue? The environment is IE11 on Windows 8.1 with Metro interface. (I don't like it but I didn't chose :) )
It seems to me that it is a bug in IE11, by now, I'm implementing a very simple workaround (easy to break) but it does work.
isIE11 = !!navigator.userAgent.match(/Trident\/7\.0/)
if isIE11
$(document).on 'click', $.rails.linkClickSelector, (event) ->
window.location.href = $(this).attr('href') unless event.defaultPrevented
I've also posted the issue in msdn.
And setup a fiddle to show the markup I'm using (but was not able to reproduce the bug there).
I can reproduce this issue every time when the link includes a block element:
<%= link_to some_path, :data => {:disable_with => 'Please wait...'} do %>
<div>click</div>
<% end %>
Breaks in older IE versions, too. Breaking test case: http://jsfiddle.net/FcXL8/4/embedded/result/ With @eloyesp 's workaround: http://jsfiddle.net/FcXL8/6/embedded/result/
I can also reproduce this bug in IE11 and Edge (v. 25.10586.0.0)
Like @pekeler I am using the link_to
helper with a block.
As long as you click on the link element itself everything works.
From the moment you click on any child nodes the link gets disabled, but nothing more.
How to fix this issue:
You need to set data-method="get"
on the link to make it work.
This is because the handleMethod
in jQuery UJS will submit a hidden (newly created) form for non-remote links to simulate the original link behavior.
@pekeler The following code should work:
<%= link_to some_path, data: {disable_with: 'Please wait...', method: :get} do %>
<div>click</div>
<% end %>