Wrong change events for space-containing field names #1455

yaroslav-ulanovych opened this Issue Jun 26, 2012 · 8 comments

5 participants


When I set the following field to a model {"a b" : 1}, two events are triggered: change:a and b, which, I believe, is neither expected nor correct behaviour.

var model = new Backbone.Model();
model.bind("change:a", function() {console.log("change:a")});
model.bind("b", function() {console.log("b")});
model.set("a b", 5);

I know that:

  • real programmers don't use spaces
  • shit in shit out

but throw exceptions or document this at least.


everything is posible !


Heya @yaroslav-ulanovych, thanks for your issue! This is definitely a result of the fact that trigger now accepts space separated events. Further, I can't find any documentation that says you shouldn't use attribute names with spaces (though I wouldn't recommend it).


We've run into this same issue, and debugging it was no fun. Space separated events seems like a strange design choice. Why not just use an array, avoiding ambiguity?

object.trigger(['a b', 'another event with a space'])

Since the trigger api is not likely to change, I've added some documentation in #1459. Thanks for pointing this out!


Any recommendation on what to do when 3rd party services are using spaces in their attribute names?

This happens to us a lot.


Sure, I would definitely translate them in model.parse.


This issue appears resolved. Should we close it?


Yep, I think so. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment