Search code examples
javascriptdom-eventsyui-datatable

YUI Datatable Blocks Enter Event of Other Components At A Page


I have a problem with selecting an option from combobox through hitting enter. Two pages are exist, one of these page uses YUI data table, while the other one does not. I have this problem only at the page with YUI datatable. After some digging, I am sure YUI data table causes a problem about enter key events of all other components at the page. If I remove YUI data table from the page, it works without any problem.

I’m using datatable-beta.js for yui-data table and we cannot replace it with a newer version. There are so many things relates to this library, so it is not wanted by the company.

I cannot use enter to select an option at a simple “html select tag” because of this problem.

How do we solve this problem? Does someone face with a similar problem about YI library?


Solution

  • You can override the method in your page so that you won't need to change the original script.

    Just override it like below (e.keyCode==13 removed) and your enter issue for that page will be solved.

    <script type="text/javascript>
    YAHOO.widget.DataTable.prototype._onDocumentKeydown=function(e,oSelf)
    {
      if((e.keyCode==27))
      {
            oSelf.cancelEditorData();
      }
    
    }
    </script>