简体   繁体   English

在jQuery和PHP中保持textarea的价值

[英]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/ 我正在使用jquery数据表,并且在http://www.datatables.net/中所述的一列中有一个textarea

The value entered in the textarea is lost when I click on sort in the column header. 当我单击列标题中的sort时,在textarea中输入的值会丢失。 I did following so far to maintain the value in dtSetup. 到目前为止,我没有做过维护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 Textarea是另一个标签,而不是input标签,请尝试此操作

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! 使用实时方式,它将应用于与选择器匹配的所有当前和将来的元素!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM