Auto-save ?

  • 1
  • Question
  • Updated 6 years ago
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members. The community moderator provided the following reason for archiving: Old Conversations

I commented on this topic before... but now its come up in a more specific way
I have a form with many tables (subforms) I want to remove as much of the controls around the table as possible
if i remove the save/cancel buttons there is no way to save new records
is there any way... maybe a piece of javascript :) .... to automatically save records when they are created in the client.. and automatically delete them when they are deleted in the client

I know this breaks your whole "batch" model.. but for subforms like these the changes will be small and the overhead is probably bearable...

Thanks

Here's an illustration
Photo of ktyler

ktyler

  • 9,274 Points 5k badge 2x thumb

Posted 6 years ago

  • 1
Photo of J.

J., Official Rep

  • 7,798 Points 5k badge 2x thumb
Ken,

I think our custom Page Title Actions functionality may work for you. Anna put together a tutorial that walks through the details. I think Step 3B is the part that will most interest you.

Basically, you can tie multiple models to a single set of Save/Cancel buttons displayed at the top of a page. Does that sound like what you need?
Photo of ktyler

ktyler

  • 9,274 Points 5k badge 2x thumb
J.
Close I think, but no cigar.... its too much scrolling
These are pretty big forms and the user would have to remember to click on the "save all" button that might be invisible at the top of the page if they're half way down the form

What i need is an "after update" hook for data entry fields that i can attach javascript to. Then for subforms like this i can attach it to the data field and every time the user updates the field i can save the model using the SKUID api

then i can remove the "save" button for the subform.

Thanks for the idea though
Photo of J.

J., Official Rep

  • 7,798 Points 5k badge 2x thumb
I think you could do that, but it would be a really, really JavaScript heavy solution. It would work like what you described: "blur" events on every element for which you would want to trigger a model.save() when that element loses focus.

Another idea I had was to do some inline CSS overriding to give that Page Title fixed positioning. It's not the prettiest solution, but it would keep the Save/Cancel button in the view at all times:

.nx-pagetitle {

position: fixed;
background-color: white;
z-index: 1;
right: 20px;
padding-left: 4px;
border: 1px solid #c5dbec;
border-radius: 4px;
}


Of course, this would apply to all page titles on the page, so if you have any that you wouldn't want to behave this way, this probably won't work.
Photo of ktyler

ktyler

  • 9,274 Points 5k badge 2x thumb
J
For these kinds of apps (only a few users, only intermittent data entry) heavy javascript flies. I have one in use now that updates the server using ajax after every field is updated.

So how do I attach to the blur event... create every control in a custom renderer ?
Photo of J.

J., Official Rep

  • 7,798 Points 5k badge 2x thumb
Ken,

I did a sanity check with Ben because it seemed like there ought to be a better way to go about this than adding a custom renderer on every field. Sure enough, he clued me in to something that might work for you:

skuid.$('body').on('change',function() { 

\\ Do your model saving, etc. here
});


However, this approach has a few potential issues. First off, only inputs, textareas, and other things that allow for an actual change of value will trigger a change event. When you click on those delete icons, it won't be considered a change, and the function won't be called. Second, the model is going to try to save as soon as you leave an input field, which will update the row, but it will also put the row back in read mode. Third, when you insert a new row inline and enter something in the first input field, it will try to save the model, and if you have any required fields, you'll get an error.

If you can work around these issues, this may do the trick.

This conversation is no longer open for comments or replies.