views:

34

answers:

1

Does anyone know how I can load a Ruby on Rails partial into a jquery dialog? I want to do something like this

$('#advancedExerciseSearchLink').click(function() {
  $('#advancedSearch').load('/path/to/advancedsearchform_partial').dialog('show');
}

I could pre-load the partial on the parent page and just show it when the advanced search button is clicked, but I'd rather dynamically load it because it keeps the initial page load lighter. I saw some suggestions for using a custom controller action, but I'd like to keep my controller RESTful if possible.

+1  A: 

Your best bet would be to create a "partials_controller.rb" with an action "advanced_search_form" with nothing in it. Then set up the appropriate route, file structure and permissions.

There's nothing not RESTful about that approach.

OR

You can place said file somewhere in the public folder. (Not Recommended as you'll have no control over access permissions.)

I don't really know any other way as jQuery won't be able to access the file because the server won't know what to do with the request.

Tom