javascript - Backbone, shall I use sync or JQuery? Can I listen for either? -
Rails the application using the backbone on the foreground, in fact I want the user to input a string and submit a submit button Pressed Two views will be updated after clicking that button I have received some great support from SO users, but have run into another problem, here are the details:
I have two models, publications and articles (with related rail models). I am using a gem (feedzira) to parse the user's login RSS URL. So I send urls / publications and can capture the ID using returned data so that I can use it as an input for post / article. Now it's time to re-present both the scenes. First of all I tried to use the backbone. Listen to the SCC function post request and change the scene and update accordingly But, since I need data from a request so I can feed it on next, I have to use $ .post () instead of .sync. This is the main reason why I do not have much information about using it. Is Sysyn possible .sync?
Click on '#', Event: {'# NU_feed': 'Forfeed'), Initialize: Function () {this.listenTo (this.model, "sync", this.render);}, render: function () {This. $ El.html (this.template ({article: this.model.toJSON ()})); Back it;}, createFeed: function (e) {e.preventDefault (); Var feed_url = $ ('# new_feed_name'). Val (); $ .post ('/ publication', {url: feed_url}, function (data) {$ .post ('/ articles / force_update', {Url: feed_url, publication_id: data.id}, function (data) {var publications = New Simple GoogleReader.Collections.Publications (); publishing.fetch ({Success: Work) {var view = new SimpleGoogleReader.Views.PublicationsIndex ({model: publication}); view.render ();}}); })}}, 'Jason')}}});
The backbone router has my home function:
home: function () {var publications = new simple irir. Selection. Publications (); Var Articles = New Simple GoogleReader.Collections.Articles (); Var pubIndex = New Simple GoogleReader.Views.PublicationsIndex ({Models: Publications}); Var Artindex = New Simple GoogleReader.Views.ArticlesIndex ({Model: Articles}); Article.listenTo (publishing, "change: shown", function () {var articles = new simple GoogleReader.Collections.Articles (); articles.fetch ({success: work (article) {var view = new SimpleGoogleReader.Views. ArticlesIndex ({Model: article}); see .render ();}}};}); publications.fetch (); articles.fetch ();}, One more thing What I am trying to do, you can see here, in order to counter the backbone sink, using postponement of post requests using JOTE. Once again after the second return I will see the publication again. So listen to me to see just articles to listen to changes in publications and update myself at that time. From what I have found, I think that you can only listen to the changes of the backbone model, Not change in its transformation. Is this true?
Please advise!
Add the following code to both of your ideas first:
start: function () {this.listenTo (this.model, "s Ync ", this.render); } and in the router:
home: function () {var publications = new simple GoogleReader.Collections.Publications (); Var Articles = New Simple GoogleReader.Collections.Articles (); Var pubIndex = New Simple GoogleReader.Views.PublicationsIndex ({Models: Publications}); Var Artindex = New Simple GoogleReader.Views.ArticlesIndex ({Model: Articles}); Article.listenTo (publishing, "sync", function () {// There is no need to create an article again // var articles = new SimpleGoogleReader.Collections.Articles (); // To bring the article now, `this.listenTo ( This.model, "sync", this.render); `// will present an article for you. Fetch ();}); Publications.fetch (); },
I think you have to call articles.fetch () here: $ Post ('/ publication', {url: feed_url}, function (data) {$ .post ('/ articles / force_update', {url: feed_url, publication_id: data.id}, function (data) {var publications = new Simple GoogleReader Collections Publishing (); Publish ({Success: Function (Publishing) {var View = New Simple GoogleReader.Views.PublicationsIndex ({model: publications}); view.render (); // here !!! !}});});}, 'Jason');
Comments
Post a Comment