The function myFunction has not been defined when using an ActiveAdmin form with Rails

I can't figure out why I am facing this issue. It seems like my hiddenField() function is not being recognized.

Here's my form :

f.input :contact, :as => :radio, :collection => ["slide", "contact form", "map", "video"], input_html: {:class => "select", :onblur => "hiddenField()"}
f.input :title_map, label: I18n.t('title_map'), input_html: {:class => "hidden_title"}, placeholder: "Enter a title for the map"

This is my Script :

var ready;
ready = function() {

    function hiddenField() {
        $(".select").on( 'click', function() {
            document.getElementsByClassName("hidden_title").removeAttribute("input");
        };
    };

    hiddenField();
};

$(document).ready(ready);
$(document).on('page:load', ready);

Thanks.

EDIT :

Apologies for forgetting to mention earlier. My form is in admin/page.rb and I'm using ActiveAdmin.

Answer №1

$(document).ready(function() {
  $('.select').on('change', function() {
    $('.hidden_title').prop('input', false);
  });
});

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

Updating a JSON array field using Symfony form manipulation

Looking to modify a Symfony entity's json_array field type by transforming it into an editable string using a text area in a form. A DataTransformer has been developed to handle the conversion between JSONString and array: /** * Convert an array to ...

I have a professional sales page showcasing data from a JSON file. My goal is to efficiently transfer details for a single listing to a separate results page

My main PHP file, index.php, successfully displays listings from a JSON file. However, I am having trouble sending the details of a single listing from this page to another page (result.php). How can I showcase the details of this individual listing on the ...

Strategies for resolving a mix of different data types within a single parameter

Here, I am setting up the options params to accept a value that can either be a single string or another object like options?: string[] | IServiceDetail[] | IServiceAccordion[]; However, when attempting to map these objects, an error is encountered: Prope ...

Is there something incorrect with the incrementation in JavaScript?

for (let i = 0; i < 5; ++i){ alert(i); } for (let i = 0; i < 5; i++){ alert(i); } Both of these constructs get the same result: 0, 1, 2, 3, 4. But what are the underlying differences between them? And does the choice of increment in a for l ...

Issue: .catch(error) function in Node / Express not returning as expectedDescription: After

I'm currently developing a REST API and focusing on effectively managing all error scenarios. Upon successful completion of the API call, I make sure to return the success object to the calling function and then send the response to the client. Howev ...

Encountering an issue of receiving an undefined value when establishing a connection between SQL Server and Node.js using

As I attempt to connect to SQL Server from node.js using the mssql package, I encounter the error message provided below: PS F:\Visual Studio Code\NodeSQLServer> node dboperations.js TypeError: Cannot read properties of undefined (reading &apo ...

Transitioning from GeometryUtils.merge() to geometry.merge()

When upgrading from r66 to r67, a message pops up stating: DEPRECATED: GeometryUtils's .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead. The transition doesn't seem straightforward beca ...

Ways to conduct a comparison of elements within an array within the same document

Is there a way to compare elements, by their index, within the same array in a MongoDB document? For example, consider the following entry: { "_id" : ObjectId("1"), "arr" : [ { "int" : 100 }, { "int" : 10 } ] } I have a collection with numerous similar e ...

Attempting to shuffle words in an array and halt the iteration after reaching 5

Looking for help with a script that randomly selects words from an array and stops after 5 iterations, always ending on the word "Amazing." Struggling to figure out the best approach - any advice on how to properly implement this would be appreciated. I b ...

React component making an Axios request only receives the initial state as a response

I'm struggling with creating an AJAX call using Axios in React. Despite my efforts, I can't seem to pinpoint where the issue lies. Below is what I currently have within my component: ComponentDidMount() { axios.get('https://jsonplacehol ...

Trouble with Ajax requests firing on document load in Firefox

When loading a JSP page in Firefox, I am invoking an AJAX function that calls a servlet. The servlet returns data in response. However, when I attempt to alert the data as shown in the code snippet below, I receive a null value. $.ajax({ url : 'S ...

Having trouble getting Bootstrap Modal to function properly

I am trying to display a modal when the window loads, but I can only see the backdrop and not the content. I am also attempting to utilize Session Storage. jQuery(document).ready(function(){ // Initializing session storage value if (s ...

The build process encountered errors related to webpack, preventing the successful compilation of nextjs CSS styles

https://i.sstatic.net/JBscR.png I'm encountering an error and struggling to determine if I'm properly importing styles and using components correctly. Can someone guide me in the right direction? Cloning github.com/branexists/nextjs (Branch: main ...

Return all HTML code from the Ajax element

I can't seem to pinpoint the issue with my code. When I make an ajax call using the code below: ajax.js: function ajaxObj(meth, url){ var x = new XMLHttpRequest(); x.open(meth, url, true); x.setRequestHeader("Content-type", "application/x-www_form-u ...

Comparison: executing an immediately invoked function expression (IIFE) and a separate

During my recent refactoring of some legacy code, I stumbled upon the following example: // within another function const isTriggerValid = await (async () => { try { const triggers = await db.any(getTriggerBeforeBook, { param ...

Guide to building a basic Table View for iOS with the help of HTML, Twitter Bootstrap, jQuery Mobile and more

I have experience with Objective-C, but I am still learning HTML/jQuery/JS. My goal is to create a Table view using these languages. Can anyone provide assistance by guiding me on how to achieve this? I was able to create a static Table view using the co ...

Converting a CSV string into an array only when there is a line break in the body

Need help to convert a CSV string into an array of array of objects. Struggling with handling \n in the incoming request, causing issues with splitting and code errors. The string format includes messages enclosed in ". "id,urn,title,body,ri ...

How to access a timeout variable from a different function within a JavaScript function

Within my JavaScript code, I have the following scenario: first_function: function() { var timeout = setTimeout(function() { // performing some actions }, 300000); }, In a separate function, once a cr ...

Leveraging the power of promises to handle multiple requests

Recently, I encountered an issue while trying to use the request-promise module to check multiple websites simultaneously. When using Promise.all as intended, the promise would return with the first rejection. I sought a better way to execute multiple requ ...

The issue arises when the input type=file data is not being successfully sent to the PHP page through the implementation

Currently, I am encountering an issue with validating file uploads in an HTML form using a jQuery plugin. The validation process works fine for empty files as it displays an error message. However, when the uploaded file has a different extension than expe ...