trestle icon indicating copy to clipboard operation
trestle copied to clipboard

Custom action with modal not working

Open dmbrooking opened this issue 3 years ago • 0 comments

In our app, we have the concept of user reviews about a product and I'm building out functionality for products to respond to the review.

Here's my code:

  ....

  column :actions, align: :center do |user_review|
    link_to('Respond', reply_user_reviews_admin_path(:reply, id: user_review.id), method: :get, class: 'btn btn-primary btn-block', data: { behavior: 'dialog' })
  end

  .....

  controller do
    def reply
      redirect_to(ugc_responses_admin_path(:new, user_review_id: params[:id]))
    end
  end

  routes do
    get :reply, on: :member
  end

and on the response admin model, I have this:

  form dialog: true do |response|
    text_area :response, rows: 5
  end

What's happening is when I click the "Respond" button, the modal for a new response displays and slides in but then about 2 seconds later, it goes away and the redirect to the new response page kicks in and it shows as a full page.

I tried removing the redirect_to and then what happens is when clicking "Respond", the page just greys out but no modal slides in.

Any idea what I am doing wrong?

dmbrooking avatar Feb 04 '22 16:02 dmbrooking