I've written a new plugin that provides a select widget that can be 
refreshed via ajax, along with a button that opens a dialog to add new 
items to the linked table. When the dialog is closed, the select widget is 
automatically refreshed via ajax and the added item(s) are available as 
selectable options. You can download or clone the file from the github 
repository: https://github.com/monotasker/plugin_ajaxselect

In one sense this is a duplication of the "select_or_add" module that has 
been available on web2py slices. Under the hood, though, they are quite 
different. My ajaxselect plugin does not manipulate the select widget on 
the user side (inserting options via jquery). Instead, I use web2py's built 
in ajax functionality to refresh the widget *from the db*. I think this 
will make for a more robust and versatile plugin.

Please test it out and let me know about (a) bugs and (b) additional 
features you would like to see (more customizability, etc.). My immediate 
plan is to expand the plugin to use the same approach for filtering the 
contents of one select widget based on the value of another.

The plugin is licensed under GPL3, so feel free to adapt and reuse it as 
you like.

Cheers,

Ian

Reply via email to