Reload Javascript after ajax event I have a module that uses a button to load an embed view everytime the button is clicked.

// function to print builder view
    function workout_builder_template() {
        $viewName = 'builder_view';
        print views_embed_view($viewName);
    }

workout_builder_template();


However after the button is pressed a new view is loaded and the view is no long ajaxified. For example, if I click the apply button after changing the exposed forms, the form submits to a new page. Before clicking the button that loads an embed view via ajax, the exposed form altered the view content via ajax.

Here is example html from the ajaxified view

&lt;form accept-charset="UTF-8" id="views-exposed-form-builder-view-default" method="get" action="/drupal7/builder-view" class="ctools-auto-submit-full-form ctools-auto-submit-processed jquery-once-1-processed"&gt;


Here is example html from the ajax less view

  &lt;form accept-charset="UTF-8" id="views-exposed-form-builder-view-default" method="get" action="/drupal7/builder-view" class="ctools-auto-submit-full-form"&gt;


In the example the ajax less view does not have processed classes added to it. From this I suspect that the new view does not get javascript attached to it after the first ajax event. I have been researching drupal.behaviors and thought about printing 

$vars['scripts'] = drupal_get_js();
print $vars['scripts'];


in the workout_builder_template() function displayed above, but I am not sure how this is done
I could be wrong here but am going to assume that the fetching of the embedded view and HTML refresh on the client-side has been done using custom Javascript code.

Once new HTML has been added to the DOM in a custom way, then to attach all Drupal behaviors defined by active modules, from within the success callback of your XHR client (say jQuery.ajax()) you might have to manually call:

// $wrapper here is the jQuery object identifying the wrapper element to
// which your new HTML has been injected to. Eg. $wrapper = $('.my-view-wrapper')
Drupal.attachBehaviors($wrapper, Drupal.settings);


My recommendation would be to try and possibly switch to the Drupal AJAX API (Documentation) as it lets you keep this refresh logic on the server-side (one place). The other, obvious benefit is that Drupal.attachBehaviors() is called for you automatically.