jhund / filterrific

Filterrific is a Rails Engine plugin that makes it easy to filter, search, and sort your ActiveRecord lists.
http://filterrific.clearcove.ca
MIT License
910 stars 124 forks source link

Best approach for use in a modal dialog with a different model? #154

Closed s0nspark closed 6 years ago

s0nspark commented 6 years ago

I am just getting started with filterrific and have, up to now, only used it in a "normal" fashion - filtering the model associated with the current controller/view.

Now, though, I'd like to use it in a bootstrap modal dialog to allow the user to look up and filter items from a different model (to associate with the current model instance) and am not entirely sure what changes in approach will be needed.

I'm thinking I will need to dynamically return not only results from the ajax call but the filterrific form as well but wasn't sure what issues that might unleash ;-)

Thoughts?

ps - thanks for such an awesome plugin!

s0nspark commented 6 years ago

After experimenting with an iframe in the modal (ugh, just ugh) I ended up solving this by using ajax in concert with the eModal bootstrap modal dialog helper. Since I used ajax to populate the modal dialog I did have to re-init filterrific to get the event handlers registered but, that aside, it proved easy enough.