Amicus/end-dash — pull request #197 by devmanhinton (2014-04-26 19:58:11+00:00)
Title: Fix trigger dom issue

@tobowers @pbadger @xcoderzach

This stops a `model.set` on the first setting of the DOM when binding the dome

a) Its not necessary (we are circularly setting in most cases or else setting `undefined` to `""`). This is because we have the model listen to the DOM and then we call `this.setFrom(variableName)`. This sets the `el` equal to the model value of the variable. This then triggers a DOM `change` (sometimes, if it doesn't that case is handled by setting `firstSetHappening` to false) which sets the property of the `el` back on the model d'oh! If the attribute on the model is `undefined`, we set that on the `el` but calling `el.val()` on a non-value input returns "". Thus we change `undefined` to `""`.

In both cases, the listener for DOM changes does `model.set(key, that.el.val(), {validate: true})` Yikes! This calls Backbone.Model.validate (thus are validators, like on the registration page, when we don't want to). Solution is, use a boolean to know when its the first set and when its not. There are probably edge cases here, so please look for those.

CHA-:ear:s