{"action":"created","issue":{"url":"https://api.github.com/repos/mikeric/rivets/issues/700","repository_url":"https://api.github.com/repos/mikeric/rivets","labels_url":"https://api.github.com/repos/mikeric/rivets/issues/700/labels{/name}","comments_url":"https://api.github.com/repos/mikeric/rivets/issues/700/comments","events_url":"https://api.github.com/repos/mikeric/rivets/issues/700/events","html_url":"https://github.com/mikeric/rivets/issues/700","id":194068334,"number":700,"title":"Updating the model from within an rv-each doesn't update the DOM","user":{"login":"maxmumford","id":3797896,"avatar_url":"https://avatars.githubusercontent.com/u/3797896?v=3","gravatar_id":"","url":"https://api.github.com/users/maxmumford","html_url":"https://github.com/maxmumford","followers_url":"https://api.github.com/users/maxmumford/followers","following_url":"https://api.github.com/users/maxmumford/following{/other_user}","gists_url":"https://api.github.com/users/maxmumford/gists{/gist_id}","starred_url":"https://api.github.com/users/maxmumford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxmumford/subscriptions","organizations_url":"https://api.github.com/users/maxmumford/orgs","repos_url":"https://api.github.com/users/maxmumford/repos","events_url":"https://api.github.com/users/maxmumford/events{/privacy}","received_events_url":"https://api.github.com/users/maxmumford/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-12-07T14:46:58Z","updated_at":"2016-12-14T19:28:35Z","closed_at":"2016-12-07T16:27:47Z","body":"Hi all,\r\n\r\nI'm trying to update my model from within an rv-each but the DOM isn't updating as a result.\r\n\r\nI use rv-each to create a bunch of inputs, one for each object in a list. On input keyup, I check the validity of the input value, and update a \"valid\" flag on the model. This all works and the console prints the correct value for the validity flag, but the DOM isn't updated as a result.\r\n\r\nMy sleuthing suggests that the model parameter passed to the validation function is a different object to the one that is bound to the DOM. \r\n\r\nHere's a simplified example on jsfiddle to show you what I'm talking about:\r\n\r\nhttps://jsfiddle.net/maxmumford/9pazye3c/2/\r\n\r\nEither I'm doing something very wrong, or this is a bug. Any help?\r\n\r\nMax"},"comment":{"url":"https://api.github.com/repos/mikeric/rivets/issues/comments/267131289","html_url":"https://github.com/mikeric/rivets/issues/700#issuecomment-267131289","issue_url":"https://api.github.com/repos/mikeric/rivets/issues/700","id":267131289,"user":{"login":"Leeds-eBooks","id":4380655,"avatar_url":"https://avatars.githubusercontent.com/u/4380655?v=3","gravatar_id":"","url":"https://api.github.com/users/Leeds-eBooks","html_url":"https://github.com/Leeds-eBooks","followers_url":"https://api.github.com/users/Leeds-eBooks/followers","following_url":"https://api.github.com/users/Leeds-eBooks/following{/other_user}","gists_url":"https://api.github.com/users/Leeds-eBooks/gists{/gist_id}","starred_url":"https://api.github.com/users/Leeds-eBooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leeds-eBooks/subscriptions","organizations_url":"https://api.github.com/users/Leeds-eBooks/orgs","repos_url":"https://api.github.com/users/Leeds-eBooks/repos","events_url":"https://api.github.com/users/Leeds-eBooks/events{/privacy}","received_events_url":"https://api.github.com/users/Leeds-eBooks/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T19:28:35Z","updated_at":"2016-12-14T19:28:35Z","body":"Ok sorry for missing this one. This actually has **nothing** to do with cloning. Here is an updated fiddle that works: https://jsfiddle.net/LeedsEbooks/9pazye3c/4/\r\n\r\nThere is another closed issue regarding this precise problem but I can't find it now. **TL;DR**: all top-level properties of the model object must be objects or arrays. Top-level primitives will not be observed for changes.\r\n\r\nThe problem derives partly from how `rivets` manages to observe your `model` object and react to changes – the rivets 'magic' if you will. It does this (by default – this can be changed of course) by assigning getters and setters for all the properties of your model. However, it treats the `model` object passed into `rivets.bind(view, model)` as a collection of models (the argument is actually named `models` in the source code) and doesn't observe the immediate properties of that object, but instead all the properties of all the immediate properties of your top-level `model` object.\r\n\r\nOne approach is to do this instead: `rivets.bind(view, {model: model})`, and then prefix all your references in your html with `model.`\r\n\r\nThe approach I use is simply to put everything in an object."}}
{"actor":{"display_login":"Leeds-eBooks"}}