ajax enabled views - load additional .js

30equals - November 9, 2009 - 22:22
Project:Views
Version:6.x-2.0
Component:page displays
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

hey

in my drupal site i have some custom jquery functions which run on a page load. the .js is been added through a drupal_add_js in my template.php
now, with ajax enabled, the .js doesn't get loaded anymore on each page of my view.

is there a views hook i should use or something, so on every ajax load, the .js gets called ?

thanx!

#1

dereine - November 9, 2009 - 23:45

You could use preprocess_page to get every activ js-files and if ajax_view.js is there you add your own.

#2

30equals - November 10, 2009 - 08:53

mmm.. i put my drupal_add_js functions in the preprocess_page now, but it's still the same.
it's not that the jquery isn't there, but my dom manipulation only works on the first page load. when applying filters or paging to my ajax enabled view, the functions don't get applied to my elements in the page.

#3

30equals - November 10, 2009 - 10:07

allright, found it!

with the following function in my .js, i can execute functions on each ajax load:

Drupal.behaviors.myBehavior = function (context) {
....

};

#4

merlinofchaos - November 10, 2009 - 16:58
Status:active» fixed

Ahh, that's just your .js not using the API correctly then.

#5

30equals - November 11, 2009 - 17:26

how so ?
my jquery is manipulating some view rows, and i added the .js in my template.php.

if there's a better way please do share it.

#6

merlinofchaos - November 11, 2009 - 18:48

Sorry, I meant the original problem. Using behaviors is the correct way. =)

#7

30equals - November 12, 2009 - 09:53

allrighty then ;)

#8

System Message - November 26, 2009 - 10:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.