By rohitm on
Here is what I want to do:
On the 'Create Page' page, I am going to add a fieldset which will have a search field for searching in the external repository. After clicking on Search, the result set will be displayed on the same page without refreshing it. Then the user will be able to select any one file and attach it to the node.
Here is the problem:
I am unable to find a way to call a specific javascript function on the click of search button which will not submit the whole page(yes, you guessed it right, something like AJAX).
Comments
Careful mixing form elements
A normal Search box is usually designed to be self-contained. i.e. the form often consists of just the 1 text field (and a few hidden fields) and the "Search" button.
You are right that an AJAX-like approach will accomplish what you need. However, you need to override the way the Search element works, such that it doesn't submit the entire form. Also, you may have a problem with nested forms - i.e. the "Create Page" is a form, but you are embedding another form (for Search) inside of it.
This is a bit tricky and will require some custom Javascript. You can use the JQuery library to build something like this, but you'll also need a service to provide the search results in-page. Normally, the Search Results are their own separate page so making them available via Service is a separate issue.
I'm not certain that you will find an existing contributed module to do something like this, especially if your "external repository" isn't within Drupal.
---------------------------------
Steven Wright
Slalom