Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make set be silent after saving model for first time

Tags:

backbone.js

I'm using backbone.js and rails. When backbone.js saves a model for the first time rails responds with the new id and backbone.js does a set on the model with the new id.

http://documentcloud.github.com/backbone/docs/backbone.html#section-41

My problem is I can't make that set be silent. That set calls a change event which causes my view to render.

like image 887
Dan Avatar asked Dec 30 '11 16:12

Dan


People also ask

Which function has to be used when you want to trigger the event only once before being removed?

js Event once() The event once method is just like event on method but it causes the bound callback to only fire once before being removed.

What is backbone in programming?

Backbone. js is a model view controller (MVC) Web application framework that provides structure to JavaScript-heavy applications. This is done by supplying models with custom events and key-value binding, views using declarative event handling and collections with a rich application programming interface (API).

Is Backbone JS still used?

Backbone. Backbone has been around for a long time, but it's still under steady and regular development. It's a good choice if you want a flexible JavaScript framework with a simple model for representing data and getting it into views.


1 Answers

You can pass an option in the save method to not trigger any events

model.save(null, { silent: true })
like image 59
Paul Avatar answered Jan 01 '23 22:01

Paul