Hello,
I have an ajax-enabled view and I would like to ask how could encapsulate javascript into a view template.

I have done it sucessfully but when the view reloads using ajax (paging, exposed filters submission), the javascript didn't loaded into the new results. Any way to accomplish this?
Thank you!

More specifically I would like to run the following code, in order to attach some javascript behavior to a custom button that I have added in each row of the results.
$('.views-button-on-each-row').on('click', function(){
.....................
});

Comments

xatiu’s picture

Any thoughts??

dawehner’s picture

Status:Active» Fixed

Just use Drupal.behaviors. (see different kind of drupal javascript related handbooks)
and it will work as expected, as the new behavior will be reattached to the new loaded content.

You sould also consider to move your javascript into another file.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.