2 Replies Latest reply on Dec 9, 2009 2:05 AM by btj

    rich:hotkey only works the first time?

      I am using the following code to capture enter in a text field..:

      <a4j:jsFunction name="searchArticles" action="#{myArticleSearchController.searchArticles}" reRender="articlesearchgrid,articlestablegroup" status="waitStatus"/>
      <rich:hotKey selector="#searchfield" key="return" handler="searchArticles();return false;"/>
      


      The problem is that the first time I press Enter, the search action is called... The next time, nothing happends....

      Am I using this wrong or is it a bug?


      Regards,

      BTJ


        • 1. Re: rich:hotkey only works the first time?
          niox

          Hi,

          Try to reRender the <rich:hotKey> too.

          Why? When the <rich:hotKey> is first rendered, it finds the client-side control based on the jQuery selector "#searchfield" and attaches an event to it. When the AJAX request reRenders the page, the old control is totally replaced, together with the old event handler.

          ReRendering the <rich:hotKey> will (hopefully) re-establish the event handler as well.

          • 2. Re: rich:hotkey only works the first time?

            Actually, what I needed to do, was to remove the rerender for my code... both the jsfunction and hotKey was in a group that was rerendered... Removing that group from rerender and now it works....


            BTJ