开发者

Grails - Dynamic file upload without page reload

This is more of an approach issue than how-to.

I have a main form/document where user can dynamicaly attach/upload files using hidden iframe.

Each time user removes/adds a file, it is deleted/persisted to database by submitting an extra form to iframe. After that I do an ajax call and render a new gsp template containg updated list of files. All without page reload. Then, if the form is successfully saved and validated, the uploaded files are linked to it. If not, they get eventualy cleaned up sometime later.

I am quite satisfied with the result but..

What I would like to know is if this is a good approach, since I always render a new template instead of DOM manipulation with javascript to provide the user the dynamic feel of file handling. Which I have seen most people do.

The one thing I can't seem to figure out is how to "localy" (hide it from user) remove the file without deleting it from database(without DOM). Atm, if the user deletes a fil开发者_运维百科e but decides not to save the main form, the file is gone anyway.

Thanks


I'm not entirely sure I understand the last part of your question, but I'm going to take a stab at it anyway. My assumption if that a user can say they want to delete a file, but not save the form, thus, the file doesn't get deleted. But when this happens, you're removing the file from the list anyway, and then it comes back on a page refresh.

If this is the correct understanding, I would recommend styling the representation of the file in some way that would indicate it is ready for deletion. Don't remove it completely. Gray it out, strikethrough, add an icon, something that says the system will delete this when you hit save.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜