lunik

Joined

30 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Nested Comment Threads in Rails - Part 1 Discussion

Hey Chris, Just to let you know your code above was very helpful in fixing my problem with simplemde not being applied to the reply text area. It works now!
Many thanks :)

Posted in Nested Comment Threads in Rails - Part 1 Discussion

Hi Chris, Thank you so much for your quick response, let me try your solution, i will keep you updated.

Posted in Nested Comment Threads in Rails - Part 1 Discussion

Hello Christ
I'm using the simplemde editor on my rails 5.0 blog site. simplemde displayed fine under the comment until i added nested comments based on this tutorial. The problem now is only the first reply textarea has simplemde attached to it correctly. but after submiting a first comment when i click reply i just get a basic textarea without simplemde attached to it.
I'm trying to achieve exactly how simplemde is being used with nested comments tread here at goRails

This is what my posts.coffee look like

simplemde = null
cleanupSimpleMDE = ->
  if simplemde?
    simplemde.toTextArea()
    simplemde = null

$(window).on 'popstate', cleanupSimpleMDE
$(document).on 'turbolinks:before-visit', cleanupSimpleMDE

$(document).on 'turbolinks:load', ->
    $mde = $(".simplemde")
    QUEUE = MathJax.Hub.queue
    if $mde.length > 0
        $mde.each (_, el) ->
            simplemde = new SimpleMDE({
                element: el,
                    ......
            })

and my form partial looks looks like this

<%=form_for([commentable, Comment.new], local: true, html: {class: local_assigns[:class], data: {target: local_assigns[:target]}}) do |form| %>
    <p class="message-area"><%=form.text_area :content, class: "simplemde", id: "md-editor"%></p>
    <%=form.hidden_field :parent_id, value: local_assigns[:parent_id]%>
    <p><%=form.error_message_for(:content)%></p>
    <div class="">
        <span class="inline-block p-r-10">
            <%=form.submit "Post reply", class: "btn btn-primary", id: "submit_comment"%>
        </span>
    </div>
<% end %>

Is there something i'm missing? Thanks for your help