Fix for quick edit file and link in announcement

Change submit_button into ajax_for_submit
This commit is contained in:
Christophe Vilayphiou 2012-04-26 16:42:28 +08:00
parent 6bf4c60d45
commit 3d293f6419
10 changed files with 49 additions and 45 deletions

View File

@ -1,4 +1,4 @@
$('#submit_button').live('click', function(){
$(document).on('click', '#ajax_form_submit', function(){
$('#ajaxForm').ajaxSubmit({
beforeSubmit: function(a,f,o) {
o.dataType = 'script';

View File

@ -6,10 +6,9 @@ $('.bulletin_files_block a.delete').live('click', function(){
$(this).parents('.list_item').remove();
});
$('.action a.remove_existing_record').live('click', function(){
$(document).on('click', '.action a.remove_existing_record', function(){
$(this).next('.should_destroy').attr('value', 1);
//$("#bulletin_" + $(this).prev().attr('value')).hide();
$("tr#bulletin_" + $(this).prev().attr('value')).hide();
$("tr #" + $(this).prev().attr('value')).hide();
});
$('.quick_edit_cancel').live('click', function(){

View File

@ -6,6 +6,7 @@
//
//= require jquery
//= require jquery_ujs
//= require jquery.form
//= require bootstrap
//= require jquery.isotope.min
//= require jquery.tinyscrollbar.min
@ -14,3 +15,4 @@
//= require tinymce_orbit
//= require orbit-bar-search
//= require side_bar_history
//= require ajax_form

View File

@ -9,7 +9,7 @@
<%= link_back %>
<%= f.submit t(:edit) %>
<% else %>
<a id='submit_button'><%= t(:edit) %></a>
<a id='ajax_form_submit'><%= t(:edit) %></a>
<% end %>
</div>
<% end %>

View File

@ -9,7 +9,7 @@
<%= link_back %>
<%= f.submit t(:create) %>
<% else %>
<a id='submit_button' class="new"><%= t(:create) %></a>
<a id='ajax_form_submit' class="new"><%= t(:create) %></a>
<% end %>
</div>
<% end %>

View File

@ -1,6 +1,6 @@
<% # encoding: utf-8 %>
<%= form_for(@bulletin_file, :remote => true, :url => @file_url) do |f| %>
<%= form_for @bulletin_file, :url => @file_url, :html => {:id => 'ajaxForm', :multipart => true} do |f| %>
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
@ -38,9 +38,9 @@
</div>
<div class="modal-footer">
<%= hidden_field_tag 'bulletin_file[bulletin_id]', @bulletin_file.bulletin_id %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
<%= hidden_field_tag 'bulletin_file[bulletin_id]', @bulletin_file.bulletin_id %>
<a class="btn btn-primary" id='ajax_form_submit'><%= t('submit')%></a>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>

View File

@ -1,18 +1,19 @@
<tr id="<%= dom_id list_bulletin_file %>">
<td><%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.zh_tw, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.zh_tw} ) : list_bulletin_file.filetitle.zh_tw %></td>
<td><%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.en, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.en} ) : list_bulletin_file.filetitle.en %></td>
<td>
<a href="<%= panel_announcement_back_end_bulletin_file_quick_edit_path(list_bulletin_file) %>#modal-file" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %>
<%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil , :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>
<tr id="<%= dom_id list_bulletin_file %>">
<td><%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.zh_tw, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.zh_tw} ) : list_bulletin_file.filetitle.zh_tw %></td>
<td><%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.en, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.en} ) : list_bulletin_file.filetitle.en %></td>
<td>
<a href="<%= panel_announcement_back_end_bulletin_file_quick_edit_path(list_bulletin_file) %>#modal-file" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %>
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id list_bulletin_file) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :_destroy, :value => nil , :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>

View File

@ -1,19 +1,15 @@
<tr id="<%= dom_id list_bulletin_link %>">
<td><%= link_to list_bulletin_link.i18n_variable.zh_tw, list_bulletin_link.url, :target => '_blank' %></td>
<td><%= link_to list_bulletin_link.i18n_variable.en, list_bulletin_link.url, :target => '_blank' %></td>
<td>
<a href="<%= panel_announcement_back_end_bulletin_link_quick_edit_path(list_bulletin_link) %>#modal-link" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= fields_for "bulletin[bulletin_links_attributes][]", list_bulletin_link, :index => list_bulletin_link_counter do |f| %>
<%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil , :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>
<tr id="<%= dom_id list_bulletin_link %>">
<td><%= link_to list_bulletin_link.i18n_variable.zh_tw, list_bulletin_link.url, :target => '_blank' %></td>
<td><%= link_to list_bulletin_link.i18n_variable.en, list_bulletin_link.url, :target => '_blank' %></td>
<td>
<a href="<%= panel_announcement_back_end_bulletin_link_quick_edit_path(list_bulletin_link) %>#modal-link" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= fields_for "bulletin[bulletin_links_attributes][]", list_bulletin_link, :index => list_bulletin_link_counter do |f| %>
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id list_bulletin_link) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>

View File

@ -1,7 +1,7 @@
<div id="qe-file" class="qe-edit-div">
<div id="widget-file">
<div class="control-group">
<table class="table table-condensed">
<table id="bulletin_files" class="table table-condensed">
<thead>
<tr>
<th>Chinese</th>

View File

@ -15,6 +15,12 @@
</div>
</div>
<div id="bulletin_file_qe">
<div id="modal-file" class="modal fade">
<%= render :partial => "bulletin_file_qe" %>
</div>
</div>
<div class="form-actions">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
</div>