Guest User

Untitled

a guest
Jul 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. $(".check_img").click(function(e) {
  4. var $img = $(this);
  5. var $form = $(this).closest('form');
  6. var $checkbox = $form.find('#post_published');
  7.  
  8. if ($checkbox.is(':checked')) {
  9. $checkbox.attr("checked", false);
  10. } else {
  11. $checkbox.attr("checked", true);
  12. };
  13.  
  14. var url = $form.attr('action');
  15. var data = $form.serialize();
  16. var callback = function(data, textStatus){
  17. };
  18. $.post(url, data, callback, "json");
  19. return false;
  20. });
  21. });
  22. </script>
  23.  
  24.  
  25.  
  26.  
  27. <div class="content">
  28. <% for post in @posts %>
  29. <div class="item">
  30. <div class="c_title"><%=h post.title %></div>
  31. <div class="c_body"><%=h post.body %></div>
  32. <div class="c_published">
  33. <% form_for post do |f| -%>
  34. <div class="<%= post.published? ? "published" : "unpublished" %>"></div>
  35. <div class="element_zone"><%= f.check_box :published %></div>
  36. <% end -%>
  37. </div>
  38. </div>
  39. <% end %>
  40. </div>
Add Comment
Please, Sign In to add comment