2017-09-11 14 views
1

我有一个jQuery的虚拟键盘工作的datatables.js应用程序。使用虚拟键盘将信息输入生成的搜索框时,过滤的内容不起作用。这意味着如果我有一列names并用虚拟键盘搜索名称(例如Airi),则数据表内的信息不会更新。如果我删除它的作品。JQuery虚拟键盘和Datatables.js搜索过滤器框不会更新用户输入

,我使用的DataTable中的代码如下:

$(document).ready(function(){ 
    $('.selectpicker').selectpicker(); 
    $('#example').DataTable(); 
    // example for the virtual keyboard on datatable search 
    // this shows the keyboard but the content is not filtered 
    function virtualKSearch() {  
     $('input[type="search"]').keyboard({ 
       layout: 'qwerty', 
       draggable: true, 
       position: { 
        of : $(window), 
        my : 'center bottom', 
        at : 'center bottom', 
        at2: 'center bottom' 
       }, 
       change: function(e, keyboard, el) { 
        keyboard.$el.val(keyboard.$preview.val()) 
        keyboard.$el.trigger('propertychange')   
       }, 
       reposition: true 
     }).addTyping(); 
     } 
    // example for the bootstrap select keyboard, this works 
    $('input[role="textbox"]').keyboard(
    { 
     layout: 'qwerty', 
     position: { 
      of: $(window), 
      my: 'center bottom', 
      at: 'center bottom', 
      at2: 'center bottom' 
     }, 
     change: function(e, keyboard, el) { 
     keyboard.$el.val(keyboard.$preview.val()) 
     keyboard.$el.trigger('propertychange')   
     } 
    }) 
    .addTyping(); 

    // datatable example 
    virtualKSearch(); 

}); 

起初我认为它曾与propertyChange做,但一些修改后,似乎并非如此。虽然我相信这个问题可能在键盘设置中change属性的内部。

含量可以这种笔内被复制:

https://codepen.io/AlecX4/pen/YrKYPv

任何提示或建议将不胜感激。

+1

要求的朋友 –

回答

1

其实,我设法修复它。对于卡上的任何人透露此事...的解决方案是非常简单:

变化

   keyboard.$el.trigger('propertychange')   

   keyboard.$el.trigger('input')