I haven't gotten to quite that level of abstraction yet, but I came up with a solution for my problem that could be helpful to some. I will think about this more and see if I can make it more generic to be reused by others, but here is what I did for now (these changes are all in jquery.treeview.async.js): in $.fn.treeview, right below the line var container = this; I added: settings.my_custom_id!=""? settings.params={current_id:settings.my_custom_id}:settings.params=null; (my_custom_id is set in the initialization of the widget) and changed the call to load to: load(settings, settings.params, this, container);
Then, within proxied.call, I changed the call to: load(settings, {id:this.id}, childList, container); Basically, I am using this to determine if I use the default of {id:some_number} or my own param that brings back the full list down to the section of the tree where I last was (this is determined serverside based on the page requested, which may not be something available in the tree). Part of what I wanted to do here was remove the logic of building the param hash in the call to getJSON. It likely needs to be further decoupled, but this is a first stab. In keeping with this plan, I changed the signature of load to be: function load(settings, params, child, container) { and getJSON just reused params instead of building them inline like so: $.getJSON(settings.url, params, function(response) { I like the idea you mentioned Jörn, so I will see if I can come up with any better thoughts on how to pull that off, and let you know if I do. Thanks for the assistance. -j On May 5, 10:01 am, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote: > I discussed the idea of jQuery core supporting dynamic data parameters > with Scott recently - we haven't made progress, but it could solve a > lot of issues like this one. Basically you'd replace "static" values > with functions that return those values, while thetreeviewplugin > just passes these through to $.ajax, which then evaluates those > functions while serializing the data. I think every plugin that uses > jQuerys ajax methods could leverage that. > > Jörn > > On Fri, May 2, 2008 at 11:35 PM, jayg <[EMAIL PROTECTED]> wrote: > > > Excellent thought. I was thinking of having some sort of parameter > > hash to pass in, maybe I can hook that together with this idea. > > > On May 2, 11:39 am, "markus.staab" <[EMAIL PROTECTED]> wrote: > > > Maybe a callback function (given some usefull context parameters..) > > > which produces the url could do the trick.. > > > > On 2 Mai, 17:24, jayg <[EMAIL PROTECTED]> wrote: > > > > > Thanks Jörn, > > > > I will post code here when I get a good solution. However, I know the > > > >treeviewis being worked on in the UI project as well, should I be > > > > > looking at something other than treview.asynch to make these changes > > > > to? Additionally, I was considering adding a 'custom' persist option, > > > > I can provide a patch if you think it would be useful (and assuming it > > > > is done generically enough). Probably also going to be looking at > > > > adding a 'loading' spinner option, unless it is there and I have just > > > > missed it. > > > > > On Apr 30, 11:42 am, Jörn Zaefferer <[EMAIL PROTECTED]> wrote: > > > > > > jayg schrieb:> I need to set up dynamic urls with async trees as > > well, though I am > > > > > > using rails, so I am looking for something more like 'foo/bar/1', > > but > > > > > > same functionality. The problem I have with the idea to use > > > > > > "source.php?id=firsttree" or something similar is that I don't know > > > > > > how many subtrees I may have - this needs to be built dynamically. > > If > > > > > > I misunderstood, and this is intended to be dynamic, a code snippet > > > > > > would be greatly helpful. If not, my thought was in the getJSON > > > > > > function of thetreeview.asynch to have _that_ create the url info > > for > > > > > > the newly returned tree. We already have this.id and could easily > > > > > > return the name of the controller and method to call. Then, at the > > > > > > end when we call $(container).treeview({add:child}), we could > > insert > > > > > > the url we created into ts setting. I may hack on this until I > > hear > > > > > > another idea, but let me know what you think of that approach. > > > > > > Ideas, especially in the form of code, are very welcome. The basic > > > > > problem, dynamic arguments and different URL formats, applies now to > > > > > bothtreeviewand autocomplete plugins, so solving it properly would > > > > > help a lot. > > > > > > Jörn