Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting {silent: true} when resetting a collection still triggers the 'reset' event

I am trying to reset my collection without triggering the 'reset' event. I have set up my collection to listen to both 'reset' and 'add' events

@.listenTo(@options.muses, 'add', @addOne)
@.listenTo(@options.muses, 'reset', @addAll)

When I click on a button, the first thing I want to do is to clear out the collection

optionButtonClicked: (e) ->
  e.preventDefault()
  target = @$(e.currentTarget)

  //step to clear out the collection
  @options.muses.reset({silent:true})

However when I did some logging and checking, I realize that the 'reset' event was still being triggered i.e. the @addAll function was still being called.

Am I missing something here? Isn't silent:true supposed to suppress the reset event?

like image 969
Zhen Avatar asked Jan 18 '13 08:01

Zhen


1 Answers

reset takes two optional parameters, models 1st, options 2nd. From the docs: resetcollection.reset([models], [options]).

so you need to pass in the silent option as the second parameter.

@options.muses.reset(undefined, {silent:true});
like image 98
hajpoj Avatar answered Oct 16 '22 18:10

hajpoj