Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript <;输入>;blur事件未在tablesorter上触发;sortBegin“;firefox中的事件_Javascript_Jquery_Tablesorter - Fatal编程技术网

Javascript <;输入>;blur事件未在tablesorter上触发;sortBegin“;firefox中的事件

Javascript <;输入>;blur事件未在tablesorter上触发;sortBegin“;firefox中的事件,javascript,jquery,tablesorter,Javascript,Jquery,Tablesorter,使用tablesorter,我在firefox中遇到以下问题 如果在向文本框添加文本后尝试按emmediatly排序,则文本框模糊事件不会始终触发 请参阅下面的代码。谢谢你的帮助 // Jscript.js $(document).ready(function () { $.tablesorter.addParser({ id: 'coltwo', is: function (s) { return false; }, format: funct

使用tablesorter,我在firefox中遇到以下问题

如果在向文本框添加文本后尝试按emmediatly排序,则文本框模糊事件不会始终触发

请参阅下面的代码。谢谢你的帮助

// Jscript.js
$(document).ready(function () {

$.tablesorter.addParser({
    id: 'coltwo',
    is: function (s) {
        return false;
    },
    format: function (s, table, cell) {
        var temp = $('input', cell).val();
        return temp.replace(",", "");
    },
    type: 'text'
});
$("#myTable").tablesorter({
    headers: {
        2: {
            sorter: 'coltwo'
        }
    }
});

//http://mottie.github.com/tablesorter/docs/#Events


//update table and focus on table to try fire blur event
$("#myTable").bind("sortBegin", function () {

    $(this).focus();

    $('#myTable').trigger("update");



});


$(".txtInput").blur(function () {

    var txt = $(this).val().replace("-",""); //remove this

    $(this).val(txt + "z"); // add text to test if blur is working

});

}); 


姓
名字
电子邮件
应得的
网站
史密斯
约翰
$50.00 
http://www.jsmith.com 
巴赫
直率的
$50.00 
http://www.frank.com 
雌鹿
杰森
$100.00 
http://www.jdoe.com 
康威
提姆
$50.00 
http://www.timconway.com 

如果我没记错的话,问题是标题上的点击事件发生在Firefox和IE中的模糊事件之前。因此更好的方法是检测
键控事件

另外,使用
updateCell
方法只更新单元格,而不是更新整个表。您可以在我的文章中了解更多有关此方法的信息

或者更好的办法是,尝试只在我的计算机上工作的解析器(下面的代码)。它无法在原始版本上工作的原因是,format
cell
参数在
updateCell
方法中出现了问题

// add parser through the tablesorter addParser method
$.tablesorter.addParser({
    id: 'inputs',
    is: function(s) {
        return false;
    },
    format: function(s, table, cell, cellIndex) {
        var $c = $(cell);
        // return 1 for true, 2 for false, so true sorts before false
        if (!$c.hasClass('updateInput')) {
            $c
            .addClass('updateInput')
            .bind('keyup', function() {
                $(table).trigger('updateCell', [cell, false]); // false to prevent resort
            });
        }
        return $c.find('input').val();
    },
    type: 'text'
});

这个解决方案怎么样

在sortbegin事件回调函数上,然后关注表中不存在的表单元素

$("#myTable").bind("sortBegin", function (e, table, cell) {

    $('#myotherinput').focus();


});

此功能可能更好/更快:

//bind to sort events
$("#yourtable").bind("sortStart",function() {
$(this).find('input:focus').trigger('blur');
});
顺便说一下,在TableSorter2.0(来自ChristianBach)中,没有 “sortBegin”。而是使用“sortStart”和“sortEnd


您可以尝试:$(document).on('blur','.txtInput',函数(){//your blur handler});谢谢,但不起作用模糊事件根本没有被触发。然后你应该尝试一下艰难的方法,比如用文本框中的当前焦点设置一个变量,当单击排序按钮时,手动触发模糊事件。感谢回复,但我不能使用keyup作为事件,因为它必须在模糊上。也许我可以在页眉上安装鼠标?还有什么想法吗?谢谢
//bind to sort events
$("#yourtable").bind("sortStart",function() {
$(this).find('input:focus').trigger('blur');
});