加载更多后jQuery效果不起作用

加载更多后jQuery效果不起作用,jquery,css,drupal,Jquery,Css,Drupal,我正在使用Drupal7,并通过页面上的查看模块获取我的内容。还有我的寻呼机模块。和我的缩略图效果悬停、阴影等。图像悬停使用以下代码: var hoverImg = '<div class="hoverimg"></div>'; $(".thumb").each(function(){ $(this).children("div").each(function(){ $(this).find("a").append

我正在使用Drupal7,并通过页面上的查看模块获取我的内容。还有我的寻呼机模块。和我的缩略图效果悬停、阴影等。图像悬停使用以下代码:

    var hoverImg = '<div class="hoverimg"></div>';

    $(".thumb").each(function(){
        $(this).children("div").each(function(){
            $(this).find("a").append(hoverImg);
        });
    });

    $(".thumb div").hover(function() {
        $(this).find(".hoverimg").animate({ opacity: 'toggle' });
    });

$(".thumb").hover(function() {
    $(this).find("div").each(function(){
        $(this).find(".shadow").fadeOut(500);
    });
});
var hoverImg='';
$(“.thumb”)。每个(函数(){
$(this).children(“div”).each(function(){
$(this.find(“a”).append(hoverImg);
});
});
$(“.thumb div”).hover(函数(){
$(this.find(“.hoverimg”).animate({opacity:'toggle'});
});
$(“.thumb”).hover(函数(){
$(this.find(“div”).each(function(){
$(this.find(“.shadow”).fadeOut(500);
});
});
并在我当前的缩略图上获取数字。此代码:

var c = '';
var d = '';
$('.view-content div.views-row').each(function(){
    c = 0;
    d = 0;
    var i = 1;
    d = $(this).find('.thumbimg').length;
    $(this).find('.thumbimg').each(function(){
        sayi=i++;
        $(this).append('<div class="img_no">0'+sayi+'</div>');
    });
});
var c='';
var d=“”;
$('.view content div.views-row')。每个(函数(){
c=0;
d=0;
var i=1;
d=$(this.find('.thumbimg').length;
$(this).find('.thumbimg').each(function(){
sayi=i++;
$(this.append('0'+sayi+'');
});
});
一切都好。开始页上的所有效果。但当单击“加载更多”按钮时,我的效果无法在另一个页面上工作

我的视图加载更多js代码:

/**
 * @file views_load_more.js
 *
 * Handles the AJAX pager for the view_load_more plugin.
 */
(function ($) {

  /**
   * Provide a series of commands that the server can request the client perform.
   */
  Drupal.ajax.prototype.commands.viewsLoadMoreAppend = function (ajax, response, status) {
    // Get information from the response. If it is not there, default to
    // our presets.
    var wrapper = response.selector ? $(response.selector) : $(ajax.wrapper);
    var method = response.method || ajax.method;
    var effect = ajax.getEffect(response);

    // We don't know what response.data contains: it might be a string of text
    // without HTML, so don't rely on jQuery correctly iterpreting
    // $(response.data) as new HTML rather than a CSS selector. Also, if
    // response.data contains top-level text nodes, they get lost with either
    // $(response.data) or $('<div></div>').replaceWith(response.data).
    var new_content_wrapped = $('<div></div>').html(response.data);
    var new_content = new_content_wrapped.contents();

    // For legacy reasons, the effects processing code assumes that new_content
    // consists of a single top-level element. Also, it has not been
    // sufficiently tested whether attachBehaviors() can be successfully called
    // with a context object that includes top-level text nodes. However, to
    // give developers full control of the HTML appearing in the page, and to
    // enable Ajax content to be inserted in places where DIV elements are not
    // allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new
    // content satisfies the requirement of a single top-level element, and
    // only use the container DIV created above when it doesn't. For more
    // information, please see http://drupal.org/node/736066.
    if (new_content.length != 1 || new_content.get(0).nodeType != 1) {
      new_content = new_content_wrapped;
    }
    // If removing content from the wrapper, detach behaviors first.
    var settings = response.settings || ajax.settings || Drupal.settings;
    Drupal.detachBehaviors(wrapper, settings);
    if ($.waypoints != undefined) {
      $.waypoints('refresh');
    }

    // Set up our default query options. This is for advance users that might
    // change there views layout classes. This allows them to write there own
    // jquery selector to replace the content with.
    var content_query = response.options.content || '.view-content';

    // If we're using any effects. Hide the new content before adding it to the DOM.
    if (effect.showEffect != 'show') {
      new_content.find(content_query).children().hide();
    }

    // Add the new content to the page.
    wrapper.find('.pager a').remove();
    wrapper.find('.pager').parent('.item-list').html(new_content.find('.pager'));
    wrapper.find(content_query)[method](new_content.find(content_query).children());
    if (effect.showEffect != 'show') {
      wrapper.find(content_query).children(':not(:visible)')[effect.showEffect](effect.showSpeed);
    }

    // Attach all JavaScript behaviors to the new content
    // Remove the Jquery once Class, TODO: There needs to be a better
    // way of doing this, look at .removeOnce() :-/
    var classes = wrapper.attr('class');
    var onceClass = classes.match(/jquery-once-[0-9]*-[a-z]*/);
    wrapper.removeClass(onceClass[0]);
    var settings = response.settings || ajax.settings || Drupal.settings;
    Drupal.attachBehaviors(wrapper, settings);
  }

  /**
   * Attaches the AJAX behavior to Views Load More waypoint support.
   */
  Drupal.behaviors.ViewsLoadMore = {
    attach: function (context, settings) {
      if (settings && settings.viewsLoadMore && settings.views.ajaxViews) {
        opts = {
          offset: '100%'
        };
        $.each(settings.viewsLoadMore, function(i, setting) {
          var view = '.view-id-' + setting.view_name + '.view-display-id-' + setting.view_display_id + ' .pager-next a';
          $(view).waypoint(function(event, direction) {
            $(view).waypoint('remove');
            $(view).click();
          }, opts);
        });
      }
    },
    detach: function (context, settings, trigger) {
      if (settings && Drupal.settings.viewsLoadMore && settings.views.ajaxViews) {
        $.each(settings.viewsLoadMore, function(i, setting) {
          var view = '.view-id-' + setting.view_name + '.view-display-id-' + setting.view_display_id + ' .pager-next a';
          $(view, context).waypoint('destroy');
        });
      }
    }
     };
})(jQuery);
/**
*@file views\u load\u more.js
*
*处理查看加载更多插件的AJAX寻呼机。
*/
(函数($){
/**
*提供服务器可以请求客户端执行的一系列命令。
*/
Drupal.ajax.prototype.commands.viewsLoadMoreAppend=函数(ajax、响应、状态){
//从响应中获取信息。如果不存在,则默认为
//我们的预设。
var wrapper=response.selector?$(response.selector):$(ajax.wrapper);
var方法=response.method | | ajax.method;
var-effect=ajax.getEffect(响应);
//我们不知道response.data包含什么:它可能是一个文本字符串
//没有HTML,所以不要正确地依赖jQuery
//$(response.data)作为新的HTML而不是CSS选择器。如果
//如果response.data包含顶级文本节点,则它们会丢失
//$(response.data)或$('').replacetwith(response.data)。
var new_content_wrapped=$('').html(response.data);
var new_content=new_content_wrapped.contents();
//出于遗留原因,效果处理代码假定新内容
//由单个顶级元素组成。此外,它尚未
//已充分测试是否可以成功调用attachBehaviors()
//使用包含顶级文本节点的上下文对象。但是
//让开发人员完全控制页面中出现的HTML,并
//允许在不包含DIV元素的位置插入Ajax内容
//允许(例如,在表、TR和SPAN父项中),我们检查新的
//内容满足单个顶级元素的要求,并且
//仅在不需要时使用上面创建的容器DIV。有关详细信息,请参阅
//信息,请参阅http://drupal.org/node/736066.
if(new_content.length!=1 | | new_content.get(0).nodeType!=1){
新内容=新内容包装;
}
//如果要从包装中删除内容,请先分离行为。
var settings=response.settings | | | ajax.settings | | Drupal.settings;
DetachBehavior(包装器、设置);
如果($.waypoints!=未定义){
$.航路点(“刷新”);
}
//设置我们的默认查询选项。这是为可能
//更改这些视图布局类。这允许它们自己在那里编写
//用jquery选择器替换内容。
var content|u query=response.options.content | |'.查看内容';
//如果我们正在使用任何效果,请在将新内容添加到DOM之前隐藏它。
if(effect.showEffect!=“show”){
新建内容.find(内容查询).children().hide();
}
//将新内容添加到页面。
find('.pager a').remove();
wrapper.find('.pager').parent('.item list').html(new_content.find('.pager'));
wrapper.find(content\u query)[method](new\u content.find(content\u query.children());
if(effect.showEffect!=“show”){
wrapper.find(content_query).children(':not(:visible))[effect.showEffect](effect.showSpeed);
}
//将所有JavaScript行为附加到新内容
//删除jQueryOnce类,TODO:需要一个更好的
//要执行此操作,请查看.removeOnce():-/
var classes=wrapper.attr('class');
var onceClass=classes.match(/jqueryonce-[0-9]*-[a-z]*/);
removeClass(onceClass[0]);
var settings=response.settings | | | ajax.settings | | Drupal.settings;
附件行为(包装器、设置);
}
/**
*将AJAX行为附加到视图以加载更多的航路点支持。
*/
Drupal.behaviors.ViewsLoadMore={
附加:功能(上下文、设置){
if(settings&&settings.viewsLoadMore&&settings.views.ajaxViews){
选项={
抵销:“100%”
};
$.each(settings.viewsLoadMore,函数(i,设置){
var view='.view id-'+setting.view_name+'.view display id-'+setting.view_display_id+'.pager next a';
$(视图).航路点(功能(事件、方向){
$(视图)。航路点(“删除”);
$(视图)。单击();
},opts);
});
}
},
分离:函数(上下文、设置、触发器){
if(设置和Drupal.settings.viewsLoadMore和设置.views.ajaxViews){
$.each(settings.viewsLoadMore,函数(i,设置){
var view='.view id-'+setting.view_name+'.view display id-'+setting.view_display_id+'.pager next a';
$(视图,上下文)。航路点(“销毁”);
});
}
}
};
})(jQuery);

我如何解决这个问题?谢谢。

将jQuery更新为1.7.1或1.7.2,并使用$.on()而不是$.hover()-使用$.on(),基本上就是给它一个“活动”处理程序,而不需要将处理程序单独附加到每个元素。使用主容器作为附加选择器,并使用.thumb和.thumb i
$('#main').on('hover', '.thumb', function() {
    // do your hover stuff
}