Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
tanks @DAddYE
  • Loading branch information
WaYdotNET committed Nov 2, 2011
1 parent 6882dec commit 01431fd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ $(function(){
keyboard: true,
backdrop: true
});
$('#save_and_continue').click(function(){
$('<input/>',{type:'hidden',id:'s_c',value:'true', name:'s_c'}).appendTo($(this).closest("form"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

.actions
=f.submit t_admin(:save), :class => 'btn primary'
=f.submit t_admin(:save_and_continue), :class => 'btn primary', :id => 'save_and_continue'
=f.submit t_admin(:save_and_continue), :class => 'btn primary', :name => 'save_and_continue'
=f.submit t_admin(:cancel), :onclick => "window.location='#{url(:<%= @orm.name_plural %>, :index)}';return false", :class => 'btn default'
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Admin.controllers :<%= @orm.name_plural %> do
@<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.name_singular}]") %>
if <%= @orm.save %>
flash[:success] = '<%= @orm.klass_name %> was successfully created.'
params[:s_c] ? redirect(url(:<%= @orm.name_plural %>, :index)) : redirect(url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id))
params[:save_and_continue] ? redirect(url(:<%= @orm.name_plural %>, :index)) : redirect(url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id))
else
render '<%= @orm.name_plural %>/new'
end
Expand All @@ -29,7 +29,7 @@ Admin.controllers :<%= @orm.name_plural %> do
@<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
if <%= @orm.update_attributes("params[:#{@orm.name_singular}]") %>
flash[:success] = '<%= @orm.klass_name %> was successfully updated.'
params[:s_c] ? redirect(url(:<%= @orm.name_plural %>, :index)) : redirect(url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id))
params[:save_and_continue] ? redirect(url(:<%= @orm.name_plural %>, :index)) : redirect(url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id))
else
render '<%= @orm.name_plural %>/edit'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ div class="clearfix"

div class="actions"
== f.submit t_admin(:save), :class => 'btn primary'
== f.submit t_admin(:save_and_continue), :class => 'btn primary', :id => 'save_and_continue'
== f.submit t_admin(:save_and_continue), :class => 'btn primary', :name => 'save_and_continue'
== f.submit t_admin(:cancel), :onclick => "window.location='#{url(:<%= @orm.name_plural %>, :index)}';return false", :class => 'btn default'

0 comments on commit 01431fd

Please sign in to comment.