2010-11-25 41 views
0
return this.each(function(){ 

    $(this).mouseenter(s,function(){ 

     s.self = $(this); 
     s.slot = $(this).attr('id').split('_')[1]; 

     s.callback = function(o){ 
      var s = {} 
      $.extend(s,o); 

      /* Ajax call, to get banner info data */       
      s.ajax = $.getJSON(domain+lng+'/banner/countbanners?slot='+s.slot,function(data){ 

       s.template = $.tmpl(s.name,$.extend(data,{ 
        slot_width:s.self.width(), 
        slot_height:s.self.height(), 
        view_href:s.view_href+s.slot 
       })); 
       s.template.appendTo(s.self); 

      }); 

     } 

     $.get_template(s); 

    }); 

    $(this).mouseleave(s,function(o){ 
     s.self.find('.banner_info_wr').remove(); 
    }); 

}); 

如何访问mouseleave内的s.ajax对象?jQuery从回调访问一些obj

在get_template函数获取模板后,调用将被调用。

感谢;)

回答

1

定义s之外的你mousenter(内each回调),您将能够访问它。

+0

你能不能请秀。它不工作:| – Somebody 2010-11-25 11:53:05