{"action":"created","issue":{"url":"https://api.github.com/repos/theironcook/Backbone.ModelBinder/issues/220","labels_url":"https://api.github.com/repos/theironcook/Backbone.ModelBinder/issues/220/labels{/name}","comments_url":"https://api.github.com/repos/theironcook/Backbone.ModelBinder/issues/220/comments","events_url":"https://api.github.com/repos/theironcook/Backbone.ModelBinder/issues/220/events","html_url":"https://github.com/theironcook/Backbone.ModelBinder/issues/220","id":84242748,"number":220,"title":"Converter applied to non-converter bindings","user":{"login":"khcoder","id":12716876,"avatar_url":"https://avatars.githubusercontent.com/u/12716876?v=3","gravatar_id":"","url":"https://api.github.com/users/khcoder","html_url":"https://github.com/khcoder","followers_url":"https://api.github.com/users/khcoder/followers","following_url":"https://api.github.com/users/khcoder/following{/other_user}","gists_url":"https://api.github.com/users/khcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/khcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khcoder/subscriptions","organizations_url":"https://api.github.com/users/khcoder/orgs","repos_url":"https://api.github.com/users/khcoder/repos","events_url":"https://api.github.com/users/khcoder/events{/privacy}","received_events_url":"https://api.github.com/users/khcoder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-02T22:36:05Z","updated_at":"2015-06-02T22:46:18Z","closed_at":null,"body":"I'm having trouble binding a single model attribute to multiple HTML elements when one of those bindings uses a converter and others do not require the converter.  \r\n\r\nStepping through the ModelBinder source, it appears that once a converter is bound to a model attribute, that converter is used for all HTML elements (even those that do not have a converter specified).  In other words, all of the HTML elements in the \"boundEls\" will have the converter applied if any of the bindings for that model attribute uses a converter.\r\n\r\nIn my case, I have an attribute \"errorMsg\" on my model that contains the error message for a model.  I'm binding errorMsg to a \"p\" element.  The message is displayed perfectly as expected until I try to use a converter to toggle the \"div\" that wraps it.  This \"p\" is wrapped in a \"div\" which contains other formatting.  If errorMsg is not defined, then I want the entire \"div\" hidden.  So, I specified a converter on the \"hidden\" HTML attribute.  The problem is that the \"p\" element gets the converted value, even though no converter is defined for the \"p\" element's binding.\r\n\r\nI can think of other ways around this (like setting a hasError attribute on the model), but I was hoping there was a way to achieve my goal without having to hang helper attributes off all my models.\r\n\r\nThanks for any help!\r\n\r\n\r\n**Here is the HTML showing the \"div\" that is toggled by the converter and the \"p\" element that should receive the text of errorMsg:**\r\n\r\n    <div id=\"errorMsg\" class=\"alert alert-danger\" role=\"alert\" >\r\n        <span class=\"sr-only\"></span>\r\n        <p id=\"errorMsg\"></p>\r\n    </div>\r\n\r\n\r\n**Below is the converter and also the bindings that are passed into ModelBinder:**\r\n\r\n```javascript\r\n //Converter returns false if a model.errorMsg is not specified, this will hide the error div:\r\nvar errorEnabledConverter = function (direction, value) { return (!value || 0 === value.length); };\r\n\r\n//Setup the bindings for modelbinder:\r\nvar bindings = {\r\n     errorMsg: '#errorMsg',\r\n     errorMsg: { selector: '#errorMsg', elAttribute: 'hidden', converter: errorEnabledConverter },\r\n     email: '#email',\r\n     oldPassword: '#oldPassword',\r\n     newPassword: '#newPassword',\r\n     confirmPassword: '#confirmPassword'\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/theironcook/Backbone.ModelBinder/issues/comments/108120878","html_url":"https://github.com/theironcook/Backbone.ModelBinder/issues/220#issuecomment-108120878","issue_url":"https://api.github.com/repos/theironcook/Backbone.ModelBinder/issues/220","id":108120878,"user":{"login":"amakhrov","id":1004015,"avatar_url":"https://avatars.githubusercontent.com/u/1004015?v=3","gravatar_id":"","url":"https://api.github.com/users/amakhrov","html_url":"https://github.com/amakhrov","followers_url":"https://api.github.com/users/amakhrov/followers","following_url":"https://api.github.com/users/amakhrov/following{/other_user}","gists_url":"https://api.github.com/users/amakhrov/gists{/gist_id}","starred_url":"https://api.github.com/users/amakhrov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amakhrov/subscriptions","organizations_url":"https://api.github.com/users/amakhrov/orgs","repos_url":"https://api.github.com/users/amakhrov/repos","events_url":"https://api.github.com/users/amakhrov/events{/privacy}","received_events_url":"https://api.github.com/users/amakhrov/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T22:46:18Z","updated_at":"2015-06-02T22:46:18Z","body":"@khcoder you have an issue in your `bindings` variable and in your html.\r\nhtml: there should be only one element with a given ID\r\nbindings: objects can't have duplicate keys (they get overriden in this case).\r\n\r\nA proper way to have multiple bindings for the same model propery is using an array:\r\n````\r\nbindings = {\r\n  'errorMessage': [\r\n    'selector1',\r\n    { selector: 'selector2', elAttribute: 'hidden', converter: errorEnabledConverter }\r\n  ]\r\n}\r\n````"}}