{"action":"created","issue":{"url":"https://api.github.com/repos/bitovi/canjs/issues/1376","labels_url":"https://api.github.com/repos/bitovi/canjs/issues/1376/labels{/name}","comments_url":"https://api.github.com/repos/bitovi/canjs/issues/1376/comments","events_url":"https://api.github.com/repos/bitovi/canjs/issues/1376/events","html_url":"https://github.com/bitovi/canjs/issues/1376","id":52600682,"number":1376,"title":"Allow can.view.attr to take an object as the second argument","user":{"login":"matthewp","id":361671,"avatar_url":"https://avatars.githubusercontent.com/u/361671?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewp","html_url":"https://github.com/matthewp","followers_url":"https://api.github.com/users/matthewp/followers","following_url":"https://api.github.com/users/matthewp/following{/other_user}","gists_url":"https://api.github.com/users/matthewp/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewp/subscriptions","organizations_url":"https://api.github.com/users/matthewp/orgs","repos_url":"https://api.github.com/users/matthewp/repos","events_url":"https://api.github.com/users/matthewp/events{/privacy}","received_events_url":"https://api.github.com/users/matthewp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-12-21T17:21:09Z","updated_at":"2015-06-30T15:18:38Z","closed_at":null,"body":"I would like to be able to pass an object as the second argument to can.view.attr. This object would be used to extend can.Control and new instances would be created for each element. `attrData` would be set on `this.options`. It would work like so:\r\n\r\n```js\r\ncan.view.attr('attr-name', {\r\n  init: function() {\r\n   // this.options.attrData\r\n  },\r\n\r\n  \"button click\": function() {\r\n\r\n  }\r\n});\r\n```\r\n\r\nCould do the same for `can.view.tag` but that might overlap too much with Components."},"comment":{"url":"https://api.github.com/repos/bitovi/canjs/issues/comments/117224911","html_url":"https://github.com/bitovi/canjs/issues/1376#issuecomment-117224911","issue_url":"https://api.github.com/repos/bitovi/canjs/issues/1376","id":117224911,"user":{"login":"dylanrtt","id":11302736,"avatar_url":"https://avatars.githubusercontent.com/u/11302736?v=3","gravatar_id":"","url":"https://api.github.com/users/dylanrtt","html_url":"https://github.com/dylanrtt","followers_url":"https://api.github.com/users/dylanrtt/followers","following_url":"https://api.github.com/users/dylanrtt/following{/other_user}","gists_url":"https://api.github.com/users/dylanrtt/gists{/gist_id}","starred_url":"https://api.github.com/users/dylanrtt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylanrtt/subscriptions","organizations_url":"https://api.github.com/users/dylanrtt/orgs","repos_url":"https://api.github.com/users/dylanrtt/repos","events_url":"https://api.github.com/users/dylanrtt/events{/privacy}","received_events_url":"https://api.github.com/users/dylanrtt/received_events","type":"User","site_admin":false},"created_at":"2015-06-30T15:18:38Z","updated_at":"2015-06-30T15:18:38Z","body":"I have been thinking a lot lately about how a higher level API for attributes might work and what I have ultimately come up with is practically a copy of can.Component with a few tweaks:\r\n\r\nhttps://gist.github.com/dylanrtt/42f56d374080cad61c16#file-demo-html\r\n\r\nI basically copied a bunch of code from can.Component, removed the parts about attaching a child scope/template and added a little bit of configuration to determine which attributes get mapped in.\r\n\r\nI had several design goals in mind:\r\n\r\n* Easily map attributes to a fully featured can.Map (prototype, define, etc.)\r\n* Fully featured can.Control (templated event handlers)\r\n* Listen to attribute changes without having to monkey with a single 'attributes' event where you check which attribute changed\r\n* Easily listen to and change scope properties without worrying about memory leaks or passing computes to a separate can.Control definition\r\n* Define which attributes are mapped to avoid standard standard HTML attributes like 'type' and 'class'\r\n\r\nMany attributes will not need all that functionality, but for the ones that do, it's nice to have a better API. There is currently a lot of copy pasta going on in my example so if you guys agree with this type of design, some substantial refactoring may have to take place to make the can.Component code more reusable."}}