How to overwrite functions in Struts2 jQuery Plugin

You want to enhance a default handler, fix a bug or just use an other jQuery plugin as the default in Struts2 jQuery Plugin? Here is a short example how to overwrite the handler function for the Autocompleter in the Struts2 jQuery Plugin.
  <sj:head />
  <script type="text/javascript">
  $.struts2_jquery.autocompleter = function($elem, options) {
	alert("my own autocompleter handler for "+options.id);
  };
  </script>

6 Comments

  1. Darshan Shroff

    Hi Johannes,

    That’s a good tip.
    Could you also suggest as to how i can have the select, blur , change topics working for me while using the Autocompleter handling a List as Select Box.

    This is very important requirement for us.

    Regards,

    Reply
    1. jogep (Post author)

      1.) Take a look how it currently works. See the autocompleter section around line 1554
      http://code.google.com/p/struts2-jquery/source/browse/trunk/struts2-jquery-plugin/src/main/resources/template/js/struts2/jquery.struts2.js

      2.) Take a look at the api and demos from jquery UI
      http://jqueryui.com/demos/autocomplete/

      3.) If you have a common solution for this Issue please create a patch and send it to me. 🙂

      Reply
  2. Jaime

    Hi,

    I’m having trouble understanding exactly what this is supposed to be doing. Would I be able to utilize this to disable the default enter/spacebar keypress events for accordions somehow with a variation of this code snippet?

    thanks!

    Reply
  3. Marco

    Hola como puedo agregra un hiperlink a tree node dinamicamente desde un json

    Reply
  4. Marco

    Hello as I can hyperlink to a tree agregra node dynamically from json

    Reply
    1. jogep (Post author)

      This should work since version 3.2.1.

      See:
      http://code.google.com/p/struts2-jquery/issues/detail?id=729.

      Code:

      Reply

Leave a Reply