Using anchor for cancel in a Form

S

Stil Gar

Hi all, Looking for best practices when it comes to submitting a form
and canceling a form in Rails.

Background:
I am leveraging a CSS dynamic that gives hover over and an embedded Icon
to all buttons in my application so most buttons are anchors in my
application. Artclie on the implementation:
http://particletree.com/features/rediscovering-the-button-element/

Looking for advise on this:
In order to keep these nice looking buttons I have to submit the form
with an anchor and cancel with an anchor tag. Is it okay to have the
cancel button just leave the page and go to a path or should I direct it
to the controller and then go to the Path ? What is the best practice?
Am I missing some kind of clean up I should be doing or is leaving the
page acceptable ?

Code:
%div
- form_for @activity, :url => { :action => "update" }, :html => {:id
=>"aform"} do |f|
= f.error_messages
%p
= f.label :title
%br
= f.text_field :title
%p
= f.label :artifact
%br
= f.select:)artifact, %w{HLD SRS IA})
%p
= f.label :milestones
%br
= f.select:)milestone, %w{M5 M4 M3})


%div
%span.buttons
%a{:href => "javascript:{}", :eek:nclick =>
"document.getElementById('aform').submit(); return false;"}
%img{:src =>"/images/img/icon-check.png", :border => "0"}
submit
%span.buttons
= link_to image_tag("/images/img/icon-delete.png",
:border=>0)+"Cancel", activity_path
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top