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 7884019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:41:17+00:00 2026-06-03T04:41:17+00:00

Q: How do I bind handlebars to an application object variable, such that when

  • 0

Q: How do I bind handlebars to an application object variable, such that when that variable updates, the handlebar data on the screen updates also?

jsfiddle: http://jsfiddle.net/kQuVG/3/

Handlebars:

<script type="text/x-handlebars">
    {{App.Player.stats.basic}} Scrap
</script>
<button>Add Scrap</button>

JavaScript:

App.Player = Em.Object.create({
    stats:{
        basic: 10,
        premium: 20
    }
});    

$('button').click(function(){
    console.log(App.Player.stats.basic);
    App.Player.stats.basic += 10;
    console.log(App.Player.stats.basic);
});

The fiddle isn’t even working, what I’d like to do is to click the button and add 10 onto the App.Player.stats.scrap value, and have that reflected in the output pane. Is this even the right way to be doing this?

Thanks in advance.

G

  • 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-06-03T04:41:19+00:00Added an answer on June 3, 2026 at 4:41 am

    There are quite a few things wrong with the fiddle. You should always be using Ember’s universal accessors when setting and getting properties on any object (even singletons and “App/Namespace global” properties). Ember also has specific naming conventions, like not using capital letters to start instances of objects (‘people’, not ‘People’). And you should also probably use the target/action interface.

    I’ve created a fiddle with these changes. http://jsfiddle.net/ud3323/Ac2hs/

    Handlebars:

    <script type="text/x-handlebars">
      {{App.playerObj.stats.basic}} Scrap <br />
      <button {{action "click" target="App.playerController"}}>Add Scrap</button>
    </script>​
    

    JavaScript:

    var get = Ember.get, getPath = Ember.getPath, set = Ember.set, setPath = Ember.setPath;
    
    App = Ember.Application.create();
    
    set(App, 'playerObj', Object.create({
        stats:Ember.Object.create({
            basic: 10,
            premium: 20
        })
    }));
    
    set(App, 'playerController', Ember.Object.create({
        click: function(view) {
            getPath(App, 'playerObj.stats').incrementProperty('basic', 10);
        }
    }));
    

    ​

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

Sidebar

Related Questions

How can you make an own function in PHP such that I can bind
My Asp.net application is hosted over Azure Cloud, In that application I do have
I have Json data that has children elements. I need to bind the store
I am building a simple Calculator application. I'm also learning how to apply the
I have nested groupboxes, which logically represent nested data structures in my application. Let's
I'm trying to bind my GridView at runtime, but I'm also trying to avoid
I'm trying to bind event handlers within a loop such as: var tabs =
I am building a simple mapping application that shows routes from each airport, which
I have a running ejabberd installation, with http-bind enabled, nginx proxy, and a mini
I have 2 keydown handlers: $(document).bind('keydown', function(e) { if (e.keyCode == 75) { //

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.