spine / spine

Lightweight MVC library for building JavaScript applications
http://spine.github.io
MIT License
3.66k stars 426 forks source link

Optionally suppress event trigger on models #28

Closed MSchmidt closed 12 years ago

MSchmidt commented 13 years ago

It would be nice if there was a way to call the various methods on a model without triggering events. This could be an additional parameter:

var task = Task.init({name: 'abc'});
task.save(false);
Task.create({name: 'abc'}, false);

Or maybe an option, so it could deal with optional validations as well:

Task.create({name: 'abc'}, {validate: false, silent: true});

What do you think? Or is this already possible and I just didn't see it?

maccman commented 13 years ago

Yes, this is definitely something I want to include in the future when I get a sec :)

chetan51 commented 13 years ago

+1

scottburton11 commented 13 years ago

+1

chetan51 commented 12 years ago

+1 again

chetan51 commented 12 years ago

I tried my hand at implementing it myself, here's the pull request.

quangv commented 12 years ago

What is the point of this? Wouldn't you want events to be called, why else would you bind them?

You can add options to various methods model.save silent:true, then on check for the option in your handlers.

Also Ajax has disabling Ajax features.

The question might of been submitted before those new features above. :)

MSchmidt commented 12 years ago

I'm closing this since it has been included at some point.

Look at http://spinejs.com/docs/ajax for details.

Spine.Ajax.disable ->
  record.destroy()
record.destroy({ajax: false})