Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Data persistence on action
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
William Hurley  
View profile  
 More options Oct 9 2012, 11:14 am
From: William Hurley <whur...@forumone.com>
Date: Tue, 9 Oct 2012 08:14:29 -0700 (PDT)
Local: Tues, Oct 9 2012 11:14 am
Subject: Data persistence on action

I have racer connected to mongo and getting updates from the UI to go
directly there and also out to other clients. But I'm wondering if there is
a way to have that step of saving to the data store and notification to
other subscribers can happen after a particular action. The use case for
this is an edit screen where the user makes edits to content and then has
the option to save or discard these edits. Having all the edits as real
time doesn't usually make sense in this case. Any suggestions on how I
might be able to achieve this? Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juzer Ali  
View profile  
 More options Oct 9 2012, 11:31 am
From: Juzer Ali <er.juzer...@gmail.com>
Date: Tue, 9 Oct 2012 08:31:29 -0700 (PDT)
Local: Tues, Oct 9 2012 11:31 am
Subject: Re: Data persistence on action

Instead of subscribing to a particular path simply fetch and set it on some
DOM events.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Hurley  
View profile  
 More options Oct 9 2012, 11:40 am
From: William Hurley <whur...@forumone.com>
Date: Tue, 9 Oct 2012 08:40:12 -0700 (PDT)
Local: Tues, Oct 9 2012 11:40 am
Subject: Re: Data persistence on action

I tried using model.fetch instead of model.subscribe and it appeared to
send updates as the form element was changed, which surprised me. In my
page render function I have:

function renderEditSite(page, model, id) {
        model.fetch('sites.' + id, function(err, site) {
                model.ref('_site', site);  

                render('edit_site', page);
        })

}

And as I make changes I'm seeing them updated in mongo.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
László Bácsi  
View profile  
 More options Oct 9 2012, 12:54 pm
From: László Bácsi <lac...@lackac.hu>
Date: Tue, 9 Oct 2012 18:54:25 +0200
Local: Tues, Oct 9 2012 12:54 pm
Subject: Re: Data persistence on action

There are two approaches for avoiding real time updates:

1. Using x-blur: <input type=text value={_someref} x-blur>

This might be good for single input forms, like search forms. It postpones
model update until the blur event on the input.

2. Skip the model binding and use a submit event handler: <form
x-bind=submit:postArticle>

I would go with this approach if the form is complex.

Best,
LacKac


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Hurley  
View profile  
 More options Oct 9 2012, 5:15 pm
From: William Hurley <whur...@forumone.com>
Date: Tue, 9 Oct 2012 14:15:29 -0700 (PDT)
Local: Tues, Oct 9 2012 5:15 pm
Subject: Re: Data persistence on action

So after the fetch set values in the model for each of the fields I'm using
and then bind to those in the various input fields and then on the submit
action subscribe, create a ref and then update that way?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
László Bácsi  
View profile  
 More options Oct 9 2012, 6:01 pm
From: László Bácsi <lac...@lackac.hu>
Date: Wed, 10 Oct 2012 00:01:02 +0200
Local: Tues, Oct 9 2012 6:01 pm
Subject: Re: Data persistence on action

Not exactly. I'd still use subscribe but wouldn't create direct binding
between the model and the form. Maybe an example will better illustrate.
I'm just jotting this down and might not work out of the box.

in the route:

    model.subscribe('articles.1', function(err, article) {
      model.ref('_article', article);
      model.set('_article_form', article.get());
      page.render();
    });

in the view:

    <form x-bind=submit:updateArticle>
      <input type=text value={_article_form.title}>
      <textarea>{_article_form.body}</textarea>
    </form>

in the controller:

    exports.updateArticle = function(e) {
      model.set('_article', model.get('_article_form'));
    }

On Tue, Oct 9, 2012 at 11:15 PM, William Hurley <whur...@forumone.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan  
View profile  
 More options Oct 9 2012, 11:47 pm
From: Ryan <ryan.pha...@gmail.com>
Date: Tue, 9 Oct 2012 20:47:56 -0700 (PDT)
Local: Tues, Oct 9 2012 11:47 pm
Subject: Re: Data persistence on action

Hi Laszlo,

That worked great! I was wondering the same thing as the original poster
and wanted to only persist my model to Mongo after the user clicks submit.

However, in my controller, I had to manually set each field like this:
model.set('_article.title', model.get('_article_form.title'));
model.set('_article.body', model.get('_article_form.body'));

Instead of being able to set it as a whole with one call like you
demonstrated. Not sure why it wouldn't let me do it that way, but my way
works fine if anyone runs into the same issue.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »