3

I'm trying to set the style of an html element and I read that I have to do it this way:

bid: {
  popUpContainerDisplay: "none",
  popUpDisplay: Ember.computed('bid.popUpContainerDisplay', function() {
    return Ember.String.htmlSafe("display: " + this.get('bid.popUpContainerDisplay'));
  })
},

then in my hbs file, I write

<div id="popUpContainer" style={{bid.popUpDisplay}}>

However, this is giving me some errors:

jQuery.Deferred exception: this.get is not a function TypeError: this.get is not a function
at Object.<anonymous> (http://localhost:4200/assets/auction-ember.js:53:77)
at ComputedPropertyPrototype.get (http://localhost:4200/assets/vendor.js:26852:28)
at Object.get (http://localhost:4200/assets/vendor.js:31759:19)
at NestedPropertyReference.compute (http://localhost:4200/assets/vendor.js:24910:28)
at NestedPropertyReference.value (http://localhost:4200/assets/vendor.js:24720:45)
at ReferenceCache.initialize (http://localhost:4200/assets/vendor.js:55111:52)
at ReferenceCache.peek (http://localhost:4200/assets/vendor.js:55085:29)
at DynamicAttribute.flush (http://localhost:4200/assets/vendor.js:58752:35)
at SimpleElementOperations.addAttribute (http://localhost:4200/assets/vendor.js:58414:36)
at SimpleElementOperations.addDynamicAttribute (http://localhost:4200/assets/vendor.js:58374:22) undefinedjQuery.Deferred.exceptionHook @ jquery.js:3846process @ jquery.js:3642

jquery.js:3855Uncaught TypeError: this.get is not a function(…)

What am I doing wrong? Thanks.

2 Answers 2

4

The get method doesn't exist inside the object where you are trying to use it.

That get method comes from Ember.Observable, that is used by the Ember.Object class. What you have to do is declare the bid property as an Ember.Object, using either extend or create, like this:

bid: Ember.Object.extend({
    popUpContainerDisplay: "none",
    popUpDisplay: Ember.computed('bid.popUpContainerDisplay', function() {
       return Ember.String.htmlSafe("display: " + this.get('bid.popUpContainerDisplay'));
    })
})
Sign up to request clarification or add additional context in comments.

1 Comment

I'm having this problem with a service, which already has Ember.Service.extend()
0

You need to put computed property out of bid.

bid: {
    popUpContainerDisplay: "none"
},
popUpDisplay: Ember.computed('bid.popUpContainerDisplay', function() {
    return Ember.String.htmlSafe("display: " + this.get('bid.popUpContainerDisplay'));
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.