Getting addClass() to run after an Ajax call (within a Drupal views table)
I've got a table, created by Views. I'm adding a class with jQuery to some of the links, something like:
$('div.view-marketplace-items .views-field-title a').addClass('test');
The table uses Ajax, both with a pag开发者_如何学编程er and with sortable table headers. What I need to do is make sure the above code runs every time the pager is used or the headers are sorted.
I've seen a function live()
, but this seems to be for binding event handlers.
I think I may need to use Drupal.behaviors, but I'm all out of brain cells at the mo in trying to understand how these work... :)
Cheers, James
You could add the class by theming the view field with php, or else via it's rewrite options in the UI. Or else if you want to use jquery, drupal.behaviors are designed to run after JS DOM changes so you may have more success using a wrapper like
Drupal.behaviors.mymoduleAddClass = function(){
$('div.view-marketplace-items .views-field-title a').addClass('test');
}
精彩评论