Attached is a patch to allow Ajax.InPlaceCollectionEditor to load the collection using AJAX.
It adds a new option, loadOptionsURL, which is the URL used to load the values over the interweb. It expects the server to return <option></option> values. If one of them has a selected="selected" attribute, it will probably be pre-selected. Not tested that though. Also only tested in FF, however the only actual new code is a line of Element.update(), so I don't foresee any X-Browser problems. As usual, development site, can't show the example to the world. Yet another patch that will never know what CVS is. Enjoy people. -Rob
--- js/controls.js.orig 2006-03-07 15:35:45.000000000 +0000 +++ js/controls.js 2006-03-07 15:35:49.000000000 +0000 @@ -784,10 +784,27 @@ this.editField = this.cached_selectTag; if(this.options.loadTextURL) this.loadExternalText(); + if(this.options.loadOptionsURL) this.loadExternalOptions(); this.form.appendChild(this.editField); this.options.callback = function(form, value) { return "value=" + encodeURIComponent(value); } + }, + loadExternalOptions: function() { + Element.addClassName(this.form, this.options.loadingClassName); + this.editField.disabled = true; + new Ajax.Request( + this.options.loadOptionsURL, + Object.extend({ + asynchronous: true, + onComplete: this.onLoadedExternalOptions.bind(this) + }, this.options.ajaxOptions) + ); + }, + onLoadedExternalOptions: function(transport) { + Element.removeClassName(this.form, this.options.loadingClassName); + Element.update(this.editField, transport.responseText); + this.editField.disabled = false; } });
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs