ember.js - "undefined is not a function" for CP and didInsertElement -
i'm wrapping js component ember addon, i've done many times before, , yet i'm running problem right @ get-go makes me worry maybe "magic" of ember has shifted slightly? anyway hoping can explain why following:
import ember 'ember'; import layout '../templates/components/nav-menu'; export default ember.component.extend({ layout: layout, tagname: 'nav', classnames: ['navmenu','navmenu-default','navmenu-fixed-left'], attributenames: ['role:navigation'], classnamebindings: ['offcanvas'], hideat: null, offcanvas: function() { let hideat = this.get('hideat'); if(!hideat) { return 'offcanvas'; } else { return 'offcanvas-%@'.fmt(hideat); } }.property('hideat'), _initialize: function() { this.$().offcanvas(); }.on('didinsertelement') });
this fails on 2 counts. as-is fails in offcanvas
computed property saying:
uncaught typeerror: undefined not function
very odd gets odder. if remove computed property fails @ _initialize()
call same "undefined not function" error:
i'm using ember 1.11.0, ember-cli 0.2.2.
you're right in related ember cli 0.2.2. the changelog:
addons have ember-disable-prototype-extensions included default, ensures add-ons written in way works regardless of consumers prototype extension preference.
i see reasoning behind change , makes total sense. need use ember.computed
, ember.on
create properties , observers. these:
initialize: function() {}.on('didinsertelement'), offcanvas: function() {}.property('hideat')
become these:
initialize: ember.on('didinsertelement', function() {}), offcanvas: ember.computed('hideat', function() {})
you can read more disabling prototype extensions here.
Comments
Post a Comment