Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(document).ready(function() {
- $(".check_img").click(function(e) {
- var $img = $(this);
- var $form = $(this).closest('form');
- var $checkbox = $form.find('#post_published');
- if ($checkbox.is(':checked')) {
- $checkbox.attr("checked", false);
- } else {
- $checkbox.attr("checked", true);
- };
- var url = $form.attr('action');
- var data = $form.serialize();
- var callback = function(data, textStatus){
- };
- $.post(url, data, callback, "json");
- return false;
- });
- });
- </script>
- <div class="content">
- <% for post in @posts %>
- <div class="item">
- <div class="c_title"><%=h post.title %></div>
- <div class="c_body"><%=h post.body %></div>
- <div class="c_published">
- <% form_for post do |f| -%>
- <div class="<%= post.published? ? "published" : "unpublished" %>"></div>
- <div class="element_zone"><%= f.check_box :published %></div>
- <% end -%>
- </div>
- </div>
- <% end %>
- </div>
Add Comment
Please, Sign In to add comment