Grails - Instant file upload without the need for refreshing the page

My approach to file attachment and handling in my main form/document is unique because I use a hidden iframe for users to dynamically upload files.

Whenever a user adds or removes a file, it undergoes a process where it gets deleted from or persisted to the database by submitting an additional form to the iframe. Following that, there is an ajax call which updates the list of files in a new gsp template without having to reload the page.

After successful validation and saving of the main form, the uploaded files are linked to it. If not, they are eventually removed at a later time.

While I am satisfied with this process, I am curious if it is considered a good approach since I constantly generate a new template instead of using JavaScript for DOM manipulation like many others do to create a dynamic feel for handling files.

The one challenge I face is figuring out how to locally hide a file from the user without deleting it from the database (without impacting the DOM). Currently, if a user deletes a file but chooses not to save the main form, the file is still permanently removed.

Any insights or suggestions would be greatly appreciated!

Answer №1

While the final portion of your inquiry isn't entirely clear to me, I'll do my best to address it nonetheless. From what I gather, a user may request to delete a file without saving the form, resulting in the file not being deleted. However, despite this, the file is still removed from the list temporarily and reappears upon refreshing the page.

If my interpretation is accurate, I suggest altering the appearance of the file to indicate that it is slated for deletion. Instead of erasing it completely, consider graying it out, adding a strikethrough, incorporating an icon, or some other visual cue that signifies the system will permanently remove the file upon saving.

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

What methods do Google and Facebook use to manage user sessions effectively?

I'm looking to incorporate a session in my asp.net application that remains active until the user logs out. I've come across this feature on websites like Google, where the session persists even after a computer restart. How do they achieve this ...

leveraging Ajax to submit a segment of the webpage

-Modified- Greetings, I am facing a situation where I need to post only the second form on a page that contains two forms. The second form has a function for validating data such as date, email, etc. My goal is to send the second form without reloading ...

extract elements from dataset

Attempting to splice an array but encountering index issues var kode_pelayanan = []; function deleteKodePelayanan(index){ kode_pelayanan.splice(index, 1); console.log(kode_pelayanan); } Experimented in the console with an array for kode_pelayanan ...

How can I access attribute type information in a Node.js Sequelize model?

I have successfully implemented a model in NodeJS using Postgres and sequelize. Let's say the model is Person and it includes fields for name and age. Now, I am looking to dynamically examine the model class to retrieve details about its attributes, s ...

What could be the reason my vue.js button is not generating a fresh textarea?

I am currently developing my first Web App with vue.js and I'm trying to implement a feature where clicking a button will generate a new textarea. It seemed to be functioning correctly when tested on jsfiddle, but once I tried running it in visual stu ...

The issue with my Wordpress frontend ajax form not functioning as expected

I've been struggling with this issue for hours now. I'm still new to Ajax, so I might be overlooking something simple. Please help me out before I pull all my hair out! In my functions.php file // Setting up the Ajax Quote Box function ajax_quo ...

The clear function in the template slot of Vue multiselect is not functioning properly

I decided to incorporate the asynchronous select feature found in the documentation for my project. This feature allows me to easily remove a selected value by clicking on 'X'. Below is a snippet of the general component that I use across variou ...

Using D3.js to plot data points on a topojson map's coordinates

Having difficulty converting latitude and longitude coordinates to "cx" and "cy" positions on my SVG map created with d3 and topojson. Despite researching solutions online, I am unable to successfully implement the conversion process. Each time I try to co ...

When employing a string union, property 'X' exhibits incompatibility among its types

In my code, I have two components defined as shown below: const GridCell = <T extends keyof FormValue>( props: GridCellProps<T>, ) => { .... } const GridRow = <T extends keyof FormValue>(props: GridRowProps<T>) => { ... & ...

I am looking to showcase the data retrieved from an API by arranging it into columns with automatic data filling in a project using React.js and MySQL

When using the onKeyUp event to trigger an API call without submitting the form, I successfully fetched data in response if the mobile number matched. However, I am struggling to understand how to display this data as a default value in columns. I have tri ...

"Using Sequelize's Op.and and Op.like operators led to an unexpected outcome of producing an empty

I am working on developing a search endpoint using express and sequelize. I noticed an issue where using Op.and in my 'where' object results in an empty object: const where = { [Op.and]: req.query.q.split(" ").map((q) => { ...

Codeigniter 3 is encountering a few unforeseen discrepancies during form validation

Currently, I am in the process of setting up a 2-step registration. The first step has been completed successfully, and now I am working on the second step. I am encountering an issue with ajax form validation where it displays an error immediately upon op ...

Create a datastring using a JSON object

When receiving data in JSON format from an AJAX call, the following code is used to parse it: var parsed=JSON.parse(data); An example output could look like this: {"confirm_type":"contract_action","job_id":12,"id":7} To generate a dynamic data string f ...

Ways to implement two functions within a single onclick event

Is it possible to call two functions with onclick event? <input id = "test" onclick="func1()"> Can I add another function as well? How would I go about doing that? ...

Having difficulties updating a value in Angular through a function written in HTML- it refuses to update

<select ng-model="currentTimeStartHour" style="width: 33%" ng-change="UpdateTime(this)"> <option ng-repeat="hour in choices" value="{{hour.id}}">{{hour.name}}</option> </select> Somewhere else on the page... {{totalHours}} Whe ...

Using the combination of Eclipse, Phonegap, and Sencha Touch will allow you to make a request to a web server that is

After setting up xampp and MySQL on my Windows PC, I successfully deployed a website locally in the "htdocs/website" directory. Everything is running smoothly! Next, I developed a mobile app located in the "htdocs/mobile" directory. Testing it with Google ...

Issue with $.ajax() functionality persists across all browsers except for Firefox

Whenever the page loads, a small script I have retrieves rental dates. Additionally, if the user selects a different month from the drop down, new dates are also fetched. Unfortunately, the site is using jQuery 1.2.3 and I'm unable to update to 1.4 d ...

Looking to retrieve the AssetLoadedFunc properties in the LoadAssets function? Wondering if you should use TypeScript or JavaScript

When I invoke this.AssetLoadedFunc within the function LoadAssets(callback, user_data) LoadAssets(callback, user_data) { this.glg.LoadWidgetFromURL("assets/Js/scrollbar_h.g", null, this.AssetLoaded, { name: "scrollb ...

What is the method for formatting within the <textarea> element?

While working on developing a comment system, I recently made the discovery that text areas cannot be formatted to retain paragraphs, line breaks, etc. This was particularly noticeable when comparing sites like StackOverflow, which uses a text editor inste ...

Loading Website Content, Track your Progress

I'm facing an issue with the website loading progress bar. The script I'm using for the progress bar is not functioning correctly on the Web server www.example.com. Even though the website is live on the web server, the problem is that the progre ...