2. What is Drupal.ajax framework?
1. Flexible framework for managing front-end
objects using backend.
2. Framework that provide easy way to develop
strong and stable projects with complex ajax
part.
3. Framework that help us save MVC pattern
more clear (more business logic in back-end).
3. Quick intro examples
1. Form ajax features (start point of the
framework).
2. AJAX updates for blocks on page.
3. Ajaxable links.
5. What we had in forms
$form['product_category_' . $basic_term->tid]['childrens'] = array(
'#type' => 'checkboxes',
'#options' => $product_titles,
'#ajax' => array(
'callback' => '_vkusno_main_search_receipt_product_ajax',
),
);
6. Drupal.ajax could be attached to links on page.
drupal_add_library('system', 'drupal.ajax');
$output[] = l(t('Ajax example'), 'our_callback',
array(
'attributes' => array(
'class' => 'use-ajax'
),
));
7. What we have in the box?
● Deliver ajax commands that can
add/change/remove DOM model.
● Works automatically with forms.
● Could be quickly added to links or DOM
elements.
● Most of business logic is stored at back-end.
● 90% tasks doesnt require any line of JS
code.
8. Command using example
1. Flag in hook menu:
$items['receipts/truncate-filters/ajax'] = array(
'page callback' => ‘receipts_flush_filters_backend',
'type' => MENU_NORMAL_ITEM,
'delivery callback' => 'ajax_deliver',
'access arguments' => array('access content'),
);
17. Drawbacks
1. Slow response on big projects.
2. Not easy to implement for div’s, p’s, span’s.
3. Non-form implementation needs hook_menu
implementation.