Hi Chris,

when you move the javascript into an external js file.
you can create an global javascript variable like this :

var sourceUrl = "";
jQuery(document).ready(function() {

  $("#itemsList").autocomplete(
  {
    source:function(request,response) {
      // do some ajax stuff here with sourceUrl
      
    }
  });
});

and now you can simply overwrite this variable in an one liner 
inside of your jsp with the correct struts2 action.

an other way for your problem is that you can copy all the
resources out of the jar file into an own folder in your WebContent.

In the <sj:head /> tag you can reference this with the scriptPath attribute.
Now you can easy extend the autocompleter section in the sources. 

Best Regards

Johannes


CRANFORD, CHRIS wrote:
> 
> I believe there are two JQuery plugins for Struts2 and I have been using
> the one from http://code.google.com/p/struts2-jquery/ for a little bit
> now.  For very basic JQuery functionality I have not found any issues
> with this plugin; however when one wishes to do something more complex,
> I am finding it's better to simply use JQuery directly; however I want
> to avoid all these scripts in my JSPs if I could.  For example:
> 
> jQuery(document).ready(function() {
> 
>   $("#itemsList").autocomplete(
>   {
>     source:function(request,response) {
>       // do some stuff here, including $.ajax 
>       // to server to get data for autocomplete widget
>     },
>     select:function(event, ui) {
>       // once an item is selected, take ui.item.value
>       // and set the value of a few other fields
>     },
>     // more options...
>   });
> });
> 
> Obviously I could very easily drop this into a JS file; however the
> source function() above needs to be able to take a Struts2 action and be
> able to create the URL that is appropriate to the current context.
> Obviously, I could write my own taglib that allows me to specify all the
> parameters, attributes, etc for such a widget and it would inject the
> javascript when the page is rendered; however I'd prefer to see if there
> is a way I can easily extend the current plugin I am using or if there
> is a better plugin I could use to get the same results or whether just
> using JQuery directly is the acceptable route in this case...
> 
> Chris
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> 
> 


-----
---
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep

-- 
View this message in context: 
http://old.nabble.com/Strut2-JQuery-tp30921546p30922159.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to