Streamlining all icons to a single downward rotation

I am currently managing a large table of "auditpoints", some of which are designated as "automated". When an auditpoint is automated, it is marked with a gear icon in the row. However, each row also receives two other icons: a pencil and a toggle button. When an automated point is running, the gear icon rotates until the process is complete. I have written some code to run all these points simultaneously, but I encountered a small issue. Clicking the button to run all points causes all three icons (gear, pencil, toggle) to rotate, which is not the desired outcome. Commenting out a specific line in the code snippet prevents this from happening, although this line is necessary for the proper execution of automated points individually. I am unsure about what to change in that line, as it should not involve clicking since the automation process does not require user interaction. The classes in that click function are associated with the gear icon.

I hope this question is straightforward and does not waste anyone's time. Thank you!

private updateAuto() {
        var self = this;
        $(".auditPointRow").each(function () {
            //self.el.on("click", ".update, .edit", function () {                    
                var row = $(this).closest(".auditPointRow");
                var id = row.data("id");
                var automated = (<string>row.data("automated")).toLowerCase() == "true";
                var running = true;
                if (automated && $(this).closest(".edit").length == 0) {
                    var gear = $(this).find(".fa");
                    var maxTurns = 120;
                    gear.css("transition", "transform linear " + maxTurns * 2 + "s");
                    gear.css("transform", "rotate(" + (maxTurns * 360) + "deg)");
                    var request = $.ajax(self.root + "api/sites/" + self.site.ID + "/auditpoints/" + id, {
                        "type": "PATCH", data: JSON.stringify([
                            {
                                Op: "Replace"
                                , Path: "/score"
                                , Value: "run"
                            }
                        ])
                    });
                    request.done(function () {
                        gear.css("transition", "").css("transform", "rotate(0deg)");
                        row.prev().find("td").css("background-color", "");
                        if (row.prev().qtip("api")) {
                            row.prev().qtip("api").destroy(true);
                        }
                    });
                }
            //}
        });
    }

Answer №1

After some troubleshooting, I was able to come up with a solution for my issue. By utilizing the .each function again, I was able to loop through all of the "gears" and rotate them accordingly.

private updateAuto() {
    var self = this;
    //$(".auditPointRow").each(function () {
        $(".update, .edit").each(function () {                    
              //Omitted additional code for brevity
        });
    //});
}

Although the result is running slowly, it is functioning as intended. If anyone has any suggestions or optimizations to improve the speed, please share them here.

Edit: Upon further inspection, I realized that looping through .each twice was causing the slowdown. Therefore, I removed the initial loop over auditPoints and focused solely on the gears instead.

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

Avoid altering the background color when adjusting the scale view on an apex chart due to changes in graph data

I have developed Apexchart components for line charts that come with a date filter picker feature. This chart is interactive and changes dynamically based on the series data provided. function DisplayChart({ series, xaxis }: { series: any; xaxis?: any }) ...

Implementing jQuery stylesheet using a bookmarklet

Here's a question that may seem silly, but I'm looking to quickly apply CSS styles to a webpage by clicking on a bookmarklet. It will definitely save me time :) For example, this code does the trick: javascript:void( jQuery( ".fancybox-overlay- ...

Sequencing numerous promises (managing callbacks)

I am encountering some challenges with promises when it comes to chaining multiple ones. I'm having difficulty distinguishing how to effectively utilize promises and their differences with callbacks. I've noticed that sometimes callbacks are trig ...

The People and Groups selection dialog is displaying incorrectly in IE 10

I've been working on a Sharepoint web application and have created a site column of type “People or Group”. This should be automatically associated with a user selection dialog as shown below: However, as you can see in the image above, the users ...

Troubleshooting issues with the Select List component in ReactJS

Having an issue with the select list as the onChange event is not triggering. Struggling to set the selected value from the list in the this.state variable. Any assistance on this matter would be greatly appreciated. class SelectActivity extends React.C ...

Achieve consistent heights for divs within table cells without the use of JavaScript

Is it possible to make two divs contained in table cells in a shared row both have the height of the taller div without using JavaScript? Take a look at this simplified example here: http://jsfiddle.net/Lem53dn7/1/ Check out the code snippet from the fidd ...

Tips for composing content on a sanitized input?

In my small application, I have a feature where a question is displayed with certain words hidden and needs to be filled in by the user. The format of the question looks like this: The {0} {1} {2} his {3} off To achieve this functionality, I wrote the f ...

Form an object using elements of a string array

Trying to convert a string array into an object. The string array is as follows : let BaseArray = ['origin/develop', 'origin/master', 'toto/branch', 'tata/hello', 'tata/world']; I want the resulting obje ...

The access to the HTTP request has been restricted

Currently, I am developing multiple applications that need to communicate with each other. To test these apps, I am using both Chrome and Firefox browsers. Strangely, the issue persists in both browsers. The issue at hand: In one of my applications (let& ...

The animated Ajax loader image is not showing up on Internet Explorer 8

After reading numerous posts, none have been able to solve my issue. To address the problem, I included an IMG tag with a style attribute (visibility:hidden) for an ajax loader gif on the page. Additionally, event handlers were added for two jQuery ajax e ...

Tips for effectively utilizing JavaScript regex to precisely match a string before triggering the submit button

I have a form in Angular with a text input field that requires the entry of lowercase letters separated by commas, like this: c, d, e, g, a, f etc... Currently, the submit button activates as soon as any part of the input matches the required format, allo ...

Styling with CSS Variables and Transforming Elements

After conducting thorough research both on this platform and via Google, I have yet to find a solution to my query: "how can CSS variables be utilized in a CSS transform?" Within the HTML header, three CSS variables and their fallback values are declared: ...

What could be causing my directive to not display my scope?

I am currently developing a directive that includes a custom controller, and I am testing the scope functionality. However, I am facing an issue where the ng-show directive is not functioning as expected when trying to test if the directive has a scope fro ...

Utilizing latitude and longitude coordinates for generating visual representations of user location data

I am working on a mobile application that allows users to capture and save information about their favorite monuments. When a user takes a photo of a monument, the app instantly records the latitude and longitude values as separate entities. Afterwards, t ...

Iterating over a column in a table to construct a text string

I'm currently working on a script to iterate through a table column and concatenate the values into a string. Here is what I have written so far: $(".ConvertSQL").click(function () { var values $(".TableQuery tr").each(function () ...

How do you populate a dropdownlistfor in ASP.NET MVC after a form

My issue is that <form> @Html.DropDownListFor(x => x.City, provinces, "--Select City--", new { @class = "dropdownList" }) @Html.DropDownListFor(x => x.district, Enumerable.Empty<SelectListItem>(), "--Select district--") < ...

Customizing Jquery Validation Engine

Currently, I am trying to set up validation for a text field that should only accept alphanumeric characters and the forward slash (/) symbol. To achieve this, I am utilizing jquery validation engine. My initial attempt involved using class="validate[requ ...

Display or hide a div element when hovering over it, while also being able to select the text within

I am trying to display and conceal a tooltip when hovering over an anchor. However, I want the tooltip to remain visible as long as my cursor is on it. Here is the fiddle link $('#showReasonTip').mouseover(function(){ $(this).parent().find(&apo ...

What is the process for using infer to determine the return type of a void function?

I am trying to gain a better understanding of how to utilize the infer keyword in TypeScript. Is this an appropriate example demonstrating the correct usage of infer? I simply want to infer the return type of the function below: const [name, setName] = u ...

Checkbox selections are not retained after navigating through pages

Every time I select a checkbox on a listing page, save it, then navigate to another page through pagination and select a checkbox there, the checkbox on my initial page gets unchecked. I've considered using AJAX to store checked checkboxes in Grails s ...