I’d been working on my little project for several month before I thought that may be my way of handling following problem is ‘somewhat’ not elegant in RoR and there are more conventional ways:
My service use some javaScript API to retrieve information from particular social network service and processing of information is performed on client side and JS environment stores result of processing. so I need to interact with user without reloading the page: particularly there are some filters I need to work.
let’s say I need to filter results of request by age of publication. And there are categories selectors. I want my application works in the following way:
1. user types number of days within publication’s age should be – there’s no any ‘submit’ or ‘apply’ filter buttons
2. filters are being applied after user clicks on category-selectors: they are main UI controllers, formed by RoR helper:
<li class="cat_selector"><%= link_to category.name, posts_path(:cat_id => category.id), :remote => true%></li>
what is the ‘usual’ method to address this problem? How can I easily ‘gather’ all control’s values in one ajax request by clicking on one of particular links?
thank you!
I would abandon the default rails Ajax handling and write your own, something along the lines of
This would cause matching links to submit themselves over ajax adding data from the form with the id
some_form. You could of course build up an arbitrary data object but it’s a lot easier to use a form if you can.