Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.5
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Jun 2009 at 16:26 UTC
Updated:
16 Mar 2022 at 10:23 UTC
Jump to comment: Most recent
Comments
Comment #1
mcrittenden commentedYou ever figure this out? I'm working on the same thing.
Comment #2
mcrittenden commentedTurns out the easiest (and probably least recommended way) is just to copy the entire function that you're working with out of the Views folder and into your theme's folder, and add your own custom callbacks there. For anybody who thinks that's kind of shady, it's also relatively easy to add callbacks anytime any ajax event is fired, even from outside that ajax event's function. More here: http://docs.jquery.com/Ajax_Events
Comment #3
vamega commentedI looked at the files in the theme folder of views, and I couldn't find out where I would have to add the custom callback code.
I think the closest I got was in the file views-view.tpl.php where I saw the line
print $pager;Is this where I would add my callback. And if this is the place. How do I do it?
Comment #4
mcrittenden commentedvamega: the file is views/js/ajax_view.js ...copy the Drupal.behaviors.ViewsAjaxView there and paste into a JS file inside your theme, and then add your callbacks right after
success: function(response) {(which is at line 82 I believe in the current ajax_view.js)Comment #6
sepla commentedSimply append a
$(document).trigger()to the success function in the views/js/ajax_view.js and implement the callback using$(document).bind().Comment #7
joanpc commentedYou just have to make a custom module
And add the callback in your .js file:
I just realized that if you define your js function on the Drupal.behaviors var it also get called after views ajax calls:
Drupal.behaviors.yourtheme = function () {alert ('hi again!');}without custom module! :)
Comment #8
nicknickoli commentedSeems like the easiest solution is
After
http://www.jaypan.com/tutorial/calling-function-after-ahah-event-drupal-...
Comment #9
B Leg commentedThere's no documentation for "ajax_data_alter" anywhere. Did this ever exist?
Comment #10
NicoDruif commentedThanks, I encountered this same problem, and used the quick and dirty solution posted by nicknickoli. I use $(document).ajaxComplete(function()) function for a callback which attaches the javascript I want. Works like a charm!
Comment #11
cyper983 commentedHi, solution #8 worked grat for me!!!
Thank you nicknickoli!!
Comment #12
justindodge commentedNote that the solution proposed in #8 will execute that javascript for all ajaxComplete events, not just the one you may be looking for.
Comment #13
psegarel commented#8 should work but it would be better to restrict the callback to a specific event...
From the JQuery docs
Comment #14
smurfxx commented#8 does not working anymore with latest version of drupal, I used that method some time ago but now it seems broken.
Can you please tell me how to trigger a custom JS function on ajaxComplete?