Got the answer! See next to last paragraph. Here's an example of what I'm doing.
I have a table called customer_sales. It has fields like date_of_order, date_required, purchase_order_number and so on. I also have a table called sales_products. It has fields like product_number, product_name and so on. These two tables are in a many-to-many relationship, so there is a relation, or link, table called customer_sale_products. It has customer_sale_id, sale_product_id and pounds_ordered, pounds_shipped, and price. I represent this with three tabs. The first tab uses an SQLFORM for the customer_sales table. Tab 2 handles the customer_sale_products table. There can be many rows from this table (many products can be on the order), so I use a hand-built table to show the rows. Some columns in the table have input fields for pounds_ordered, pounds_shipped and price. When any of those fields get changed, a jquery/ajax script updates the server db and echoes the change back to the browser. There is also a delete button in the browser table. If the user clicks it, it deletes the row in the db table. The third tab holds a similar table containing available products that *could* be ordered. Same columns except there is an add button instead of a delete button. If the user clicks the add button, a jquery/ajax script signals the server to add a row to the customer_sale_products table to link this particular customer sale to the chosen product. This all works fine. So let's say there's a customer sale record, but the user forgot to put in the requested ship date and forgot one of the products. So the customer opens the record and on tab 1 types in the requested ship date. Then he jumps to tab 3, types in the information for the forgotten product and clicks add. He then closes the page, never having clicked the Submit button, so his edit is lost. I also just realized how to fix this. All of the tab 2 and tab 3 interactions get triggered when a field is changed. But the Ajax call can also include the fields from the form on tab 1 and the server side script can update them as well. Thanks for helping me think through this. On Tuesday, April 10, 2012 5:16:01 PM UTC-4, Richard wrote: > > But just to understand, you want to refresh your fk field from form > present in the other tabs? > > If it is the case I can provide code example how I realize that with the > help of Anthony just ask... > > Richard > > On Tue, Apr 10, 2012 at 5:03 PM, Cliff <[email protected]> wrote: > >> Richard, >> >> I am using jquery tabs. They work great. Also a good diagnostic for >> javascript syntax errors because the tabs stop working if the js is broken. >> >> I may have to look harder at components. Right now I'm using SQLFORM or >> crud to manage the record from the main table and jquery on_change events >> to manage records from foreign tables. >> >> Thanks for the hint on comet_message. I'll be looking for it as soon as >> I post this. >> >> >> On Tuesday, April 10, 2012 2:40:39 PM UTC-4, Richard wrote: >> >>> why not using jquery ui tabs plugin and web2py component? >>> >>> Richard >>> >>> On Mon, Apr 9, 2012 at 5:40 PM, Derek wrote: >>> >>> I'd put a warning saying "you have unsaved changes." or perhaps only >>>> allow switching after saving. You could also make your own form, and >>>> handle >>>> saving all changes with your controller. Web2py has good defaults, and the >>>> helpers are good for getting a website up and running quickly, but when >>>> you >>>> have custom logic needs, you should get your hands dirty by writing your >>>> own code. >>>> >>>> >>>> On Monday, April 9, 2012 6:19:32 AM UTC-7, Cliff wrote: >>>>> >>>>> Using the dog-owner model from the examples, you might have a model >>>>> like this: >>>>> >>>>> db.define_table('dog', Field('dog_name')) >>>>> db.define_table('owner', Field('owner_name')) >>>>> db.define_table('dog_owner', >>>>> Field('dog_id', db.dog), >>>>> Field('owner_id', db.owner), >>>>> Field('owner_plays_fetch_with_****dog', 'boolean) >>>>> ) >>>>> >>>>> I like to use tabs to edit a relationship like this on one web page. >>>>> >>>>> I would use an SQLFORM or a crud form on the first tab to present the >>>>> owner data for editing. This data gets processed in the normal way. >>>>> >>>>> I would put the dog data on a second tab, but use jquery ajax to >>>>> handle changes. Maybe the dog's name changes, or the owner decides to >>>>> start playing fetch-the-stick with the dog. >>>>> >>>>> The problem with this approach is that you can lose changes made on >>>>> the owner page. If you, for example, need to edit both the owner's name >>>>> and the dog's name, you might type the owner's new name on tab 1, move to >>>>> tab 2 and edit the dog's name, then close the page without going back to >>>>> tab 1 and clicking Submit. >>>>> >>>>> There are several possible solutions. >>>>> >>>>> - Put the owner and dog information on separate forms with submit >>>>> buttons. They may or may not be on different tabs. The drawback is it >>>>> takes a round trip to the server every time a user switches between dog >>>>> information and owner information. >>>>> >>>>> - Use jquery/ajax on the owner page to record changes as they are >>>>> made. If the user is making a lot of changes on a form, I'm not sure >>>>> there >>>>> is a good way to give feedback. >>>>> >>>>> - Use some kind of form-dirty javascript to remind the user to submit >>>>> the form on the first tab if he tries to close the page while it still >>>>> has >>>>> unsaved changes. >>>>> >>>>> Which approach would you use, or would you handle this in a different >>>>> way? >>>>> >>>>> Thank you. >>>>> >>>> >>> >

