Use Ctools Autosubmit
dereine — 15. Juni 2010 - 11:26
Since version 1.7 of ctools there is a new js api to auto-submit certain form elements.
Everytime a user changes a selectfield or inputs something into a textfield a button will be clicked automatically by js.
It's really easy to implement for your form:
- First you need to add the js
// Add ctools specific js.
ctools_add_js('auto-submit'); - Assign the autosubmit for a certain button:
// Add autosubmit button.
$form['submit']['#attributes']['class'] = $form['submit']['#attributes']['class'] ? $form['submit']['#attributes']['class'] . ' ctools-use-ajax ctools-auto-submit-click' : 'ctools-use-ajax ctools-auto-submit-click'; - Autosubmit every element in a form(there is a patch for it.)
// Add classes to every form element.
$form['#attributes']['class'] = $form['#attributes']['class'] ? $form['#attributes']['class'] . ' ctools-auto-submit-full-form': 'ctools-auto-submit-full-form'; - Autosubmit a single form element:
$form['foo']['#attributes']['class'] = 'ctools-auto-submit';
As a result you could for example implement this for every exposed form of a view, see http://github.com/dereine/Views-autosubmit-exposed_form
This was initial developed for ctools export-ui goodness.



Kommentar hinzufügen