Issue with jquery_ujs: Font Awesome spinning icon animation functions properly in Chrome but not in Safari

I've integrated font-awesome-rails into my Rails project. When a user clicks the submit button on a form:

  • The submit button should display an animated font-awesome spinner and change text to "Submitting...".
  • The button must be disabled to prevent multiple form submissions.

The provided code functions perfectly in Google Chrome:

<%= f.button "Submit", class: "btn btn-success", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> Submitting..."} %>

However, in Safari:

  • The button is disabled successfully.
  • But, the spinner icon doesn't appear and the text remains unchanged.

To demonstrate this issue, I created a small application. You can find the repository here. Try submitting the `blog` form in Chrome and then in Safari to see that the animation only works in Chrome.

I came across this jquery_ujs issue, which offers some complex workarounds but no convenient solution applicable to all scenarios where I want to include this functionality.

This seems to be a browser-related problem. For instance, Safari may avoid certain processing tasks post-form submission to maintain efficiency.

Chris Oliver from GoRails pointed out that executing the following command in the console triggers the desired effect even in Safari:

$.rails.disableFormElement($("button"))

This proves that the effect works in Safari, but binding it to a form submission button causes issues. I tested this with Safari versions 9.1.2 and 10.0.1, as well as Rails 4.2.6 and Rails 5.

Answer №1

There seems to be a potential quick solution... Take a look at this JSFiddle, which presents an even simpler demonstration of the issue. I have personally experienced a 70% failure rate with page refresh on Safari 10.1.

We can address this by enforcing the use of hardware acceleration with CSS:

form {
  -webkit-transform: translate3d(0,0,0);
  transform: translateZ(0); 
}

After applying this fix, the problem disappears.

Note: theoretically, the first line of CSS should suffice to enable hardware acceleration, but in this case, the second line is crucial for resolving the issue...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In Javascript, the color can be changed by clicking on an object, and the color

Looking for help with my current HTML code: <li><a href="index.php" id="1" onclick="document.getElementById('1').style.background = '#8B4513';">Weblog</a></li> The color changes while clicking, but when the lin ...

The dropdown navigation bar fails to close upon being clicked

I'm currently facing an issue with the navbar in my project. The bootstrap navbar doesn't close automatically after clicking on a link. I have to move my mouse away from the navbar for it to close, which is not ideal. Additionally, I'm worki ...

Using jQuery UI Dialog to delay the appearance of content after :after in IE8

My current approach involves using the :after selector to include asterisks next to required labels: .field-name { color: #444; font-family: verdana; font-size: 0.85em; line-height: 2em; } .field-name.required:after { content: '*&a ...

Using a single jQuery script, implement multiple modals on a webpage that are responsive on both desktop and mobile devices

My Modal is functioning well on desktop, but I'm facing an issue on mobile where the screen doesn't close when clicking outside the modal area. Is there a way to solve this for mobile without adding the 'X' button to close it? I attem ...

Remove the innerHTML content of dynamically added elements using jQuery

After researching, it seems that event handlers are commonly added using methods such as .live(), .on(), .bind(), or .delegate(). My previous question may not have been clear, so I decided to delete it and ask a simpler one. Is there a way to clear the in ...

Loading content dynamically into a div from an external or internal source can greatly enhance user experience on a website. By

As I work on my website, I am incorporating a div structure as shown below: <div class="container"> <div class="one-third column"> <a id="tab1" href="inc/tab1.html"><h2>tab1</h2></a> </div> & ...

I am attempting to activate the HTML5 color picker's popup using JQuery

Is there a way to open a color picker in a popup window when an input[type=color] is clicked, using JavaScript? HTML <div id="customColorPick"></div> <input id="customColorPickInput" type="color" /> JQuery $("#customColorPick").click( ...

Navigating from a web address to making an asynchronous request using history.js

As I work on a small website that features multiple pages with similar layouts, I often find that only the content within a specific div varies. The rest of the elements such as navigation and header remain consistent throughout. To address this, I have s ...

Pagination in the jQuery datatables plugin is not functioning as expected

Help Needed I am using the datatables jQuery Plugin to display a table, but I am facing an issue where all entries are shown without any pagination. Can someone please assist me with this problem? Below is my index.cshtml code: @{ Layout = null; } & ...

Button from Material-UI vanishes upon being clicked

I encountered an issue with a button that disappears when clicked on. Additionally, clicking the button once does not trigger any actions associated with it. In order to execute the button actions, I have to click the area where the button was located afte ...

Retrieve Vue.js component property within an Ajax function

When dealing with a component function that fetches data from an URL and attempts to set that data to a property, there seems to be an issue where this is not accessible from the AJAX closure scope. var MyComp = Vue.extend({ props: { html_pro ...

Loading jquery dialog content using ajax

I have run into an issue while trying to load a form into a jQuery dialog via AJAX. When checking in Firebug, I noticed that the request URL contains a strange parameter like "_=1283928792723", which is causing the request to fail with a 406 Not Acceptable ...

Switching between dark and light mode in Ant Design

I have successfully implemented dark mode toggling in my application. However, when I try to switch back to light mode, the CSS does not seem to be reloading properly. Below is the code snippet: //ThemeContext.jsx const DarkTheme = lazy(() => import(". ...

Sequentially loading Bootstrap columns as the page loads

Is there a way to load columns one by one with a time gap when the page is loaded? Here's the code snippet that can achieve this: setTimeout(function() { $("#box1").removeClass("noDisplay"); },1000); setTimeout(function() { ...

Leverage JavaScript to customize the appearance of existing links within an external HTML document

Forgive me for my lack of expertise in Javascript. I will do my best to explain clearly. On my website, I have an external html file for the navigation menu that is loaded with javascript to simplify editing (so I don't need to update nav elements on ...

Tips on generating an HTML element using JavaScript and storing it in a MySQL database

I need help with saving a created element to the database so that it remains on the page even after refreshing. Any assistance would be greatly appreciated. Thank you. document.getElementById("insert").onclick = function(){ if(document.getElementById( ...

The align-content property in CSS Flex does not function properly when used alongside an inline height declaration

I encountered an issue with the CSS Flex property align-content. It seems to not work properly in a container where the height is declared inline. However, once I move the inline height declaration to a separate CSS class, everything works fine. Both Chrom ...

Modifying the Color of Individual Items within the Pagination Component in MUI

I am attempting to modify the background color of every item in my Pagination component by utilizing makeStyles. import { Pagination } from "@material-ui/lab"; import { makeStyles } from "@material-ui/core"; const pagination = makeStyl ...

JQuery fails to remove the "display:hidden" attribute

List of methods I attempted: Utilizing .removeClass and addClass functions Applying show() and hide() methods Modifying the CSS properties Initially, I confirmed that my script contains onLoad. Furthermore, all other elements are functioning correctly. D ...

What is the method for displaying an asterisk in a select box option?

Is there a way to append an asterisk after the first option in a select element? Here is my html <select class="form-control textyformcontrol"> <option selected>Service area</option> <option>First Option</option> &l ...