{"action":"created","issue":{"url":"https://api.github.com/repos/artf/grapesjs/issues/972","repository_url":"https://api.github.com/repos/artf/grapesjs","labels_url":"https://api.github.com/repos/artf/grapesjs/issues/972/labels{/name}","comments_url":"https://api.github.com/repos/artf/grapesjs/issues/972/comments","events_url":"https://api.github.com/repos/artf/grapesjs/issues/972/events","html_url":"https://github.com/artf/grapesjs/issues/972","id":307281952,"number":972,"title":"[FEATURE REQUEST] Allow Trait API clients to override and use initlialize method of TraitView class","user":{"login":"vrudikov","id":493714,"avatar_url":"https://avatars2.githubusercontent.com/u/493714?v=4","gravatar_id":"","url":"https://api.github.com/users/vrudikov","html_url":"https://github.com/vrudikov","followers_url":"https://api.github.com/users/vrudikov/followers","following_url":"https://api.github.com/users/vrudikov/following{/other_user}","gists_url":"https://api.github.com/users/vrudikov/gists{/gist_id}","starred_url":"https://api.github.com/users/vrudikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrudikov/subscriptions","organizations_url":"https://api.github.com/users/vrudikov/orgs","repos_url":"https://api.github.com/users/vrudikov/repos","events_url":"https://api.github.com/users/vrudikov/events{/privacy}","received_events_url":"https://api.github.com/users/vrudikov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-21T15:00:08Z","updated_at":"2018-03-24T15:18:53Z","closed_at":null,"author_association":"NONE","body":"**Current behaviour:**\r\nWhen traits get added with `TraitView.addType` method they are extend `TraitsViewer.itemView`(which is `TraitView`). When `TraitSelectView` class extends `TraitView` it overrides `initialize(o)` method and calls `TraitView.prototype.initialize.apply(this, arguments);` to initialize parent class(as i understand). This allows `TraitSelectView` to override some initializing logic. For example override `this.tmpl` and use custom template for a trait\r\n\r\nFor a custom trait with overridden `initialize` method there we gonna see an error:\r\n![image](https://user-images.githubusercontent.com/493714/37717320-5a5ef5a4-2d31-11e8-8c09-e8b1f59c5ed6.png)\r\n\r\n```\r\neditor.TraitManager.addType('attrNoVal', {\r\n   initialize (o) { console.log('TEST') },\r\n})\r\n```\r\nBut with the following code everything works perfect and i can override a `this.tmpl` and do other things dirty :) things:\r\n```\r\neditor.TraitManager.addType('attrNoVal', {\r\ninitialize (o) {\r\n      // Dirty hack :) But it works\r\n      editor.TraitManager.getTraitsViewer().itemView.prototype.initialize.apply(this, arguments)\r\n    },\r\n})\r\n```\r\n\r\n**Expected behaviour:**\r\nAllow Trait API clients to override and use initlialize method of TraitView class so we can easily customize initializing logic of a trait"},"comment":{"url":"https://api.github.com/repos/artf/grapesjs/issues/comments/375897188","html_url":"https://github.com/artf/grapesjs/issues/972#issuecomment-375897188","issue_url":"https://api.github.com/repos/artf/grapesjs/issues/972","id":375897188,"user":{"login":"artf","id":11614725,"avatar_url":"https://avatars0.githubusercontent.com/u/11614725?v=4","gravatar_id":"","url":"https://api.github.com/users/artf","html_url":"https://github.com/artf","followers_url":"https://api.github.com/users/artf/followers","following_url":"https://api.github.com/users/artf/following{/other_user}","gists_url":"https://api.github.com/users/artf/gists{/gist_id}","starred_url":"https://api.github.com/users/artf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artf/subscriptions","organizations_url":"https://api.github.com/users/artf/orgs","repos_url":"https://api.github.com/users/artf/repos","events_url":"https://api.github.com/users/artf/events{/privacy}","received_events_url":"https://api.github.com/users/artf/received_events","type":"User","site_admin":false},"created_at":"2018-03-24T15:18:53Z","updated_at":"2018-03-24T15:18:53Z","author_association":"OWNER","body":"Hi @vrudikov I didn't get what do you suggest. Would you like to have some kind of `init()` method which acts as a callback after the initialization?"}}
{"actor":{"display_login":"artf"}}