Rebinding hoverIntent jQuery plug-in

I am using a combination of Drupal Views, ajax and the hoverIntent plug-in to display content. Problem is, after an ajax request the 'hoverIntent' event is no longer bound to the my selector (in this case each row of the view). Does anyone have a solution to this? [Link to plug-in uncompressed hoverIntent js](http://cherne.net/brian/resources/jquery.hoverIntent.js) [hoverIntent home page](http://cherne.net/brian/resources/jquery.hoverIntent.html) My code below-- hoverIntent: This expands a row if you're cursor is over it and at the same time collapses all other rows. $('.view-latest-new .views-field-field-story-lead-image-fid').addClass('expand'); var config = { over: function() { var expand = $(this).find(".expand"); if(expand.css("display") == "none") { $(".expand").slideUp("fast"); $(this).find(".expand").slideDown("fast"); } }, out: function() { } }; $('.view-home .views-row').hoverIntent(config); **EDIT:** Ajax: var container = $('#content-inner'); $('#block-menu-secondary-links a').bind('click', function(){ var trigger = $(this); var arg = trigger.attr('title'); doAjax(arg,container); return false; }); function doAjax(arg,container){ $.ajax({ url: 'views/ajax?view_name=home&view_display_id=page_1&view_args'+arg, timeout:5000, success: function(data){ var result = Drupal.parseJson(data); updateContainer(result.display); }, }); }; function updateContainer(content){ container.html(content); $('.view-latest-new .views-field-field-story-lead-image-fid').addClass('expand'); $('.view-latest-new .views-row').hoverIntent(config); } Thanks! **EDIT 2:** I've found a solution; by adding `$('.view-home .views-row').hoverIntent(config);` into the updateContainer function. I'm not sure if this is the best way to go about it though. But it works.

以上就是Rebinding hoverIntent jQuery plug-in的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏