Forum: Ruby on Rails Scaffold Display Changes When Destroying Records

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Brandon (Guest)
on 2006-04-02 11:24
Hi all,

I just upgraded to Rails 1.1.0 and noticed a strange error.  I created a
test application with one model that has two data fields.  I generated
the scaffold for the model and controller, and created some test data.

When I click on the scaffold-generated "Destroy" link, extra whitespace
underneath the "Destroy" link flashes on the screen until the destroy
action reloads the list of data.  Totally weird.  It's more of an
annoyance because the display actually changes for a split-second, but I
want to know if anyone has seen this problem.  How can I prevent the
whitespace from appearing while destorying a record?

Brandon
Brandon (Guest)
on 2006-04-02 11:31
On closer examination of the source of my file, I found this code
snippet that controls the delete dialog box:

<a href="/bookmarks/destroy/27" onclick="if (confirm('Are you sure?')) {
var f = document.createElement('form'); this.parentNode.appendChild(f);
f.method = 'POST'; f.action = this.href; f.submit(); };return
false;">Destroy</a>

The "form" element that the deletion confirmation creates is the cause
of the extra whitespace when the "Yes" button on the dialog box is
clicked.  If I style the "form" element with a margin and padding of
0px, the whitespace does not appear when I destroy a record.

I understand the security need to make a destroy request a POST
request... but it seems like an extra step to create a form style that
will "hide" the whitespace that is created when destroying an element.

Is there any other way around this besides removing :post -> 'true' from
my link_to action?

Brandon
This topic is locked and can not be replied to.