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({ $('#ajaxForm').ajaxSubmit({
beforeSubmit: function(a,f,o) { beforeSubmit: function(a,f,o) {
o.dataType = 'script'; o.dataType = 'script';

View File

@ -6,10 +6,9 @@ $('.bulletin_files_block a.delete').live('click', function(){
$(this).parents('.list_item').remove(); $(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); $(this).next('.should_destroy').attr('value', 1);
//$("#bulletin_" + $(this).prev().attr('value')).hide(); $("tr #" + $(this).prev().attr('value')).hide();
$("tr#bulletin_" + $(this).prev().attr('value')).hide();
}); });
$('.quick_edit_cancel').live('click', function(){ $('.quick_edit_cancel').live('click', function(){

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<% # encoding: utf-8 %> <% # 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"> <div class="modal-header">
<a class="close" data-dismiss="modal">×</a> <a class="close" data-dismiss="modal">×</a>
@ -39,7 +39,7 @@
<div class="modal-footer"> <div class="modal-footer">
<%= hidden_field_tag 'bulletin_file[bulletin_id]', @bulletin_file.bulletin_id %> <%= hidden_field_tag 'bulletin_file[bulletin_id]', @bulletin_file.bulletin_id %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %> <a class="btn btn-primary" id='ajax_form_submit'><%= t('submit')%></a>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a> <a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div> </div>

View File

@ -7,8 +7,9 @@
<span class="action"> <span class="action">
<%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %> <%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %>
<%= f.hidden_field :id %> <%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a> <%= hidden_field_tag :tr, (dom_id list_bulletin_file) %>
<%= f.hidden_field :should_destroy, :value => nil , :class => 'should_destroy' %> <a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :_destroy, :value => nil , :class => 'should_destroy' %>
<% end %> <% end %>
</span> </span>
</td> </td>

View File

@ -1,4 +1,3 @@
<tr id="<%= dom_id list_bulletin_link %>"> <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.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><%= link_to list_bulletin_link.i18n_variable.en, list_bulletin_link.url, :target => '_blank' %></td>
@ -7,13 +6,10 @@
<span class="action"> <span class="action">
<%= fields_for "bulletin[bulletin_links_attributes][]", list_bulletin_link, :index => list_bulletin_link_counter do |f| %> <%= fields_for "bulletin[bulletin_links_attributes][]", list_bulletin_link, :index => list_bulletin_link_counter do |f| %>
<%= f.hidden_field :id %> <%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a> <%= hidden_field_tag :tr, (dom_id list_bulletin_link) %>
<%= f.hidden_field :should_destroy, :value => nil , :class => 'should_destroy' %> <a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %> <% end %>
</span> </span>
</td> </td>
</tr> </tr>

View File

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

View File

@ -15,6 +15,12 @@
</div> </div>
</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"> <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' %> <%= 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> </div>