I have a block, of which I want to update the contents via AJAX. So the block is:

```
$block['subject'] = t('My Block');
$block['content'] = '<div id="block_wrapper"></div>';

```

And the form element AJAX part:

```
$form['select_element']['#ajax'] = array(
  'callback' => 'ajax_callback',
  'wrapper' => 'block_wrapper',
  'method' => 'replace',
);

```

The callback:

```
function ajax_callback($form, $form_state) {
  return views_embed_view('view_name', 'default', $form_state['values']['select_element']);
}

```

However when I change the form element the whole block content is replaced and the wrapper is replaced by a empty div, so subsequent alterations of the select element fail to update the block. 

The [wrapper documentation](https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#ajax_wrapper) explains the entire div is replaced, not just it contents. But many modules (like for example Views) have dynamically updating form elements where changing a select element toggles other parts of a form, which keeps working no matter how often you change it. Do they insert the wrapper div again in the response? And how should I alter the response of views\_embed\_view to put the contents in a wrapper div?