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

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -