开发者

jquery + autoresize re-bind on ajax loaded divs

I use the following module to do auto-scaling on my textareas

http://james.padolsey.com/javascript/jquery-plugin-autoresize/

It works great till I load some new textareas via ajax. I'm use to just switching .click with .live('click', fn) and it works fine.. but not this time.

My js to init auto-resize looks like

$('textarea.comment_entry').autoResize({
    onResize : function() {
        $(this).css({opacity:0.8});
    },
    animateCallback : function() {
        $(this).css({opacity:1});
   开发者_运维技巧 },
    animateDuration : 300,
    extraSpace : 10
});

I was using the infinite scroll plugin and this was the magic

$('div#content').infinitescroll({

  navSelector  : "a#next:last",            
  nextSelector : "a#next:last",   
  itemSelector : "#content div.content_box",
  donetext     : ""
},function(posts){
    $('textarea.comment_entry').autoResize({
        onResize : function() {
            $(this).css({opacity:0.8});
        },
        animateCallback : function() {
            $(this).css({opacity:1});
        },
        animateDuration : 300,
        extraSpace : 10
    });
});


Can you add the plugin to the new textareas on the success:function() of the ajax response?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜