map

Zénobe Grammestraat 34,
2018 Antwerp, Belgium

Call us: +32 (0) 3 298 69 98
Email us: info@krimson.be

Contact us

Friday, 06 February 2009

We were facing a big problem with Ajax and Views combined with forms.

Here's the situation we found ourselves in:

- We had a form with a lot of fields and also a markup field.
- In the markup field we embedded a view that has sortable columns.
- We do an Ajax refresh of our form so that when we hit submit, our view is refreshed without a page refresh.

Sounds ideal no? We always have a refreshed view, we submitted our values and all of this with the wonderful AHAH Helper module.

Imagine we have 3 columns (Name, Item, Date) and Item and Date are sortable.

1st time page display:

  1. URL Item: http://somelink/viewpage/15?order=item&sort=asc

After we hit submit... our view is refreshed Ajax-wise:

  1. URL Item: http://somelink/ahah_helper/library_info?order=title&sort=asc&library_info[user_info]=15&library_info[included_fieldsets]=1&library_info[fieldset1][item_information]=testing55&library_info[fieldset1][uitgeleend_tot][date]=2009-02-17&form_build_id=form-7113012bcefb22370f4dff1dcc8f7135&form_token=19bcf3b86b570cf5acfc05afbdfb6757&form_id=_vti_library_new_loan_form&op=Save%20items

Woaah, mayday mayday. Our links are dramatically changed into some ahah_helper Ajaxy things. If we click on it we see Ajax responses like :

  1. { "status": true, "data": "", "settings": { "basePath": "/", "admin_menu": { "margin_top": 1 } } }

I assume this is not something a user likes to see, at least we don't like it!

Solutions that we tried?

1) link alter
2) find and replace in views_embed_view result
3) find some views hook to alter my links

All of these solutions didn't work out as good as we wanted. Underestimating the power of views we tried one last thing that came up in our mind ...

4) Enable Ajax in that view that was embedded (in views interface).

Magic had happened! It worked without a glitch. Suddenly our links were not changed but now views is catching our Ajax links and refreshing. So AHAH Helper and Views AJAX is working nicely together with 1 simple click.

Thank you views! Thank you AHAH Helper!

Written by

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <h4> <br>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options