javascript - JQuery DOM manipulation and event trigger -
i attempting build simple edit-in-place feature new rails app. need changes save data.
how take div info top , enter in hidden form :content save edit-in-place changes?
my current show.html page follows
<p id="notice"><%= notice %></p> <div id="body_editable" class="editable"> <%= @article.content %> </div> <%= form_for(@article) |f| %> <%= f.label :content %><br> <%= f.hidden_field :content %> <div class="actions"> <%= f.submit %> </div> <% end %> <script> var editor = new mediumeditor('.editable'); </script>
i assuming following needed:
//on page load bring data div $('#body_editable').html($('#article_content').val()); //on save take div , put in form :content $('#article_content').val(editor.serialize().body_editable.value);
but not sure how trigger save event using rails submit button
try:
$('select submit').click(function(e){ e.preventdefault(); $('#article_content').val(editor.serialize().body_editable.value); $(this).closest('form').submit(); });
Comments
Post a Comment