开发者

maintain value of textarea in jquery and php

I am using jquery Datatables and I have a textarea in one column as described at http://www.datatables.net/

The value entered in the textarea is lost when I click on sort in the column header. I did following so far to maintain the value in dtSetup. But the blur event is not working.

 $('#dtSetup input[type=text]').blur(function() {

    txtMessageArr.push([this.id, this.val() ]);


    });

'fnDrawCallback': function(开发者_开发百科) {
    var oTable = $('#dtSetup').dataTable();

    $('input[type=textarea]', oTable.fnGetNodes()).each(function(){
                                    if($.inArray(this.id, txtMessageArr)>=0)
                                            this.value = txtMessageArr[$.inArray(this.id, txtMessageArr)][0];
                                    });


}


Textarea is another tag and not an input tag, try this

var txtMessageArr = [];

$('#dtSetup textarea').blur(function() {

    txtMessageArr.push([this.id, $(this).html()]);

});


this should work:

var txtMessageArr = [];

$('#dtSetup textarea').live('blur',function() {

    txtMessageArr.push([this.id, this.val() ]);

});

When the datatable date is reloaded, all the events attached to is lost. Using live means, it will apply it to all current and future elements matching the selector!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜