Question

The ActiveScaffold list view has a search form that is loaded via ajax when a user click the search link. I'd prefer to have the form show by default when a user opens a list page.

I've figured out a way to trigger the ajax call when the page loads, but I'm wondering if there's a way to get ActiveScaffold to render the form automatically. Is there a template or a method I can override? I've had a look through the code but there's nothing obvious, at least to me.

Update:

srboisvert's answer inspired me to have a better look.

The trick is to use Template overrides to refactor the following: list.rhtml, _list_header.rhtml, _search.rhtml so that the search form partial renders inline.

Was it helpful?

Solution

There is a way to get it rendered automatically:

active_scaffold :model do |config| config.list.always_show_search = true end

OTHER TIPS

I don't currently have an active scaffold project handy but here is how I would figure it out.

I'd use firefox with firebug installed and take a look at what is called when the link is clicked. Then I would go look at that javascript and what it is generating. Then I would search the source for any part of the code or combination that would be fairly unique to the search box ajax. After that it should be easy to cut and past it in without the ajaxyness.

The option

config.list.always_show_search = true

works fine, but only on concrete controller. It throws an exception when used in AS set_default block. Somebody know better solution then to include it in every controller (apart from overriding the template which is handy but complicates version updates)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top