Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7195147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:31:13+00:00 2026-05-28T20:31:13+00:00

I created an example on jsfiddle . I’ll also drop the code here: Javascript:

  • 0

I created an example on jsfiddle. I’ll also drop the code here:

Javascript:

window.App = Ember.Application.create();

TypeA = Ember.Object.extend({
  propertyA: ""
});

TypeB = Ember.Object.extend({
  propertyB: ""
});

App.someController = Ember.ArrayProxy.create({
    content: []
});

var aa = TypeA.create({propertyA: "aa"});
var ab = TypeA.create({propertyA: "ab"});
var ba = TypeB.create({propertyB: "ba"});
var bb = TypeB.create({propertyB: "bb"});

// I'm probably just copying the string here so sort of realizing
// that the binding "breaks", however I don't get how to maintain the "bond".
App.someController.pushObject(aa.get("propertyA"));
App.someController.pushObject(ab.get("propertyA"));
App.someController.pushObject(ba.get("propertyB"));
App.someController.pushObject(bb.get("propertyB"));

// I'd like this to update the value "aa" in the list
aa.set('propertyA', "AA"); 

HTML:

<script type="text/x-handlebars">
  {{#collection contentBinding="App.someController" tagName="ul"}}
    {{content}}
  {{/collection}}
</script>

So the source of the entries in someController can be various different objects, but the bond between the property of the object and the entry in someController should be preserved. Any easy way to do this? I thought of wrapping the values in someController in some object or view but I can’t find how to create a binding to a non “global” object (all the bindings I saw seemed to use a full “global” path, eg "App.someObject.property")

Any ideas much appreciated! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:31:15+00:00Added an answer on May 28, 2026 at 8:31 pm

    Okay so I figured it out with help from Veebs post. I wound up wrapping the strings (originating from the property) in an object of the form:

    Ember.Object.create({
        obj: obj,
        out: function() { 
            return this.get('obj').get(property); 
        }.property('obj.' + property)
    });
    

    Evidently, when a property of an object changes, the object is (somehow) marked changed with it, so by saying that out depends on obj it picks up changes in obj.property.

    So here is the original code with the changes:

    window.App = Ember.Application.create();
    
    TypeA = Ember.Object.extend({
        propertyA: "",
        propertyC: ""
    });
    
    TypeB = Ember.Object.extend({
        propertyB: "",
    });
    
    App.someController = Ember.ArrayProxy.create({
        content: []
    });
    
    var a = TypeA.create({propertyA: "aa", propertyC: "ac"});
    var b = TypeA.create({propertyB: "bb"});
    
    function createWrapper(obj, property) {
        return Ember.Object.create({
            obj: obj,
            out: function() { 
                return this.get('obj').get(property); 
            }.property('obj.' + property)
        });
    }
    
    App.someController.pushObject(createWrapper(a, "propertyA"));
    App.someController.pushObject(createWrapper(a, "propertyC"));
    App.someController.pushObject(createWrapper(b, "propertyB"));
    
    setTimeout(function() {
        a.set('propertyA', "AA");
        a.set('propertyC', "AC");
        b.set('propertyB', "BB");
        a.set('propertyA', "AA2"); 
    },2000);
    

    …and the (slightly changed) template:

    <script type="text/x-handlebars">
        {{#collection contentBinding="App.someController" tagName="ul"}}
            {{content.out}}
        {{/collection}}
    </script>
    

    (also available on jsfiddle)

    Thanks for the help!

    Edit: Second thought, this didn’t work, at least not when the update happens after some time. Goddamn it.
    Edit: Updated to fixed version, yay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created an example of the problem here: http://jsfiddle.net/jXLSW/ Notice that when you hover
Here is a jsfiddle example. I have created a div and marked is as
I have created a example here: http://jsfiddle.net/zidski/TFBqf/7/ This is not working: var a =
I've created this example here... http://jsfiddle.net/rhvbG/5/ var buttons=[ '<svg version=1.1 id=Layer_1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink x=0px
When reusing code (for example, a Util library you created), do you add its
Our application has many controls that are created dynamically. For example, a navigation pane
In theory, Dalvik executes any virtual machine byte code, created for example with the
I've re-created a simple version of what I'm trying to do here (jsFiddle) The
It's hard to explain, so I created an example: jsfiddle My idea is to
Example to demonstrate the issue can be found here: http://jsfiddle.net/Byyu2/ As you can see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.